github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/mxjson/parser_fuzz_test.go (about)

     1  //go:build go1.18
     2  // +build go1.18
     3  
     4  package mxjson_test
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/lmorg/murex/test/count"
    10  	"github.com/lmorg/murex/utils/mxjson"
    11  )
    12  
    13  func FuzzParser(f *testing.F) {
    14  	tests := []string{``, "[\n  1,\n  2,\n  3\n]", `{ "key: "#value" }`, `{ "key": ({ value }) }`}
    15  	for _, tc := range tests {
    16  		f.Add(tc) // Use f.Add to provide a seed corpus
    17  	}
    18  	f.Fuzz(func(t *testing.T, orig string) {
    19  		count.Tests(t, 1)
    20  		mxjson.Parse([]byte(orig))
    21  		// we are just testing we can't cause an unhandled panic
    22  	})
    23  }