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

     1  //go:build go1.18
     2  // +build go1.18
     3  
     4  package parser_test
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/lmorg/murex/test/count"
    10  	"github.com/lmorg/murex/utils/parser"
    11  )
    12  
    13  func FuzzParser(f *testing.F) {
    14  	tests := []string{"", "out: hello world", "bg { err: abc 123 }", "bob -> ? | =>"}
    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  		parser.Parse([]rune(orig), len(orig))
    21  		// we are just testing we can't cause an unhandled panic
    22  	})
    23  }