From: Joe Tsai Date: Fri, 24 Feb 2023 09:46:09 +0000 (-0800) Subject: encoding/json: remove legacy fuzz.go file X-Git-Tag: go1.21rc1~1466 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8367e2dfc72f626cba75be71112d42fdb2ed82f7;p=gostls13.git encoding/json: remove legacy fuzz.go file With native support for fuzzing in the Go toolchain, rely instead on the fuzz tests declared in fuzz_test.go. Change-Id: I601842cd0bc7e64ea3bfdafbbbc3534df11acf59 Reviewed-on: https://go-review.googlesource.com/c/go/+/471197 Reviewed-by: Johan Brandhorst-Satzkorn Reviewed-by: Than McIntosh Reviewed-by: Dmitri Shuralyov Reviewed-by: Daniel Martí Run-TryBot: Joseph Tsai Auto-Submit: Joseph Tsai TryBot-Result: Gopher Robot --- diff --git a/src/encoding/json/fuzz.go b/src/encoding/json/fuzz.go deleted file mode 100644 index b8f4ff2c1d..0000000000 --- a/src/encoding/json/fuzz.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build gofuzz - -package json - -import ( - "fmt" -) - -func Fuzz(data []byte) (score int) { - for _, ctor := range []func() any{ - func() any { return new(any) }, - func() any { return new(map[string]any) }, - func() any { return new([]any) }, - } { - v := ctor() - err := Unmarshal(data, v) - if err != nil { - continue - } - score = 1 - - m, err := Marshal(v) - if err != nil { - fmt.Printf("v=%#v\n", v) - panic(err) - } - - u := ctor() - err = Unmarshal(m, u) - if err != nil { - fmt.Printf("v=%#v\n", v) - fmt.Printf("m=%s\n", m) - panic(err) - } - } - - return -}