(f *testing.F)
| 142 | } |
| 143 | |
| 144 | func FuzzQuoteBytes(f *testing.F) { |
| 145 | const prefix = "prefix" |
| 146 | f.Add([]byte(nil)) |
| 147 | f.Add([]byte("\n")) |
| 148 | f.Add([]byte("sample text")) |
| 149 | f.Add([]byte("sample q'u'o't'e's")) |
| 150 | f.Add([]byte("select 'quoted $42', $1")) |
| 151 | |
| 152 | f.Fuzz(func(t *testing.T, input []byte) { |
| 153 | got := string(sanitize.QuoteBytes([]byte(prefix), input)) |
| 154 | want := oldQuoteBytes(input) |
| 155 | |
| 156 | quoted, ok := strings.CutPrefix(got, prefix) |
| 157 | if !ok { |
| 158 | t.Fatalf("result has no prefix") |
| 159 | } |
| 160 | |
| 161 | if want != quoted { |
| 162 | t.Errorf("got %q", got) |
| 163 | t.Fatalf("want %q", want) |
| 164 | } |
| 165 | }) |
| 166 | } |
nothing calls this directly
no test coverage detected