MCPcopy
hub / github.com/jackc/pgx / FuzzQuoteBytes

Function FuzzQuoteBytes

internal/sanitize/sanitize_fuzz_test.go:144–166  ·  view source on GitHub ↗
(f *testing.F)

Source from the content-addressed store, hash-verified

142}
143
144func 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}

Callers

nothing calls this directly

Calls 2

QuoteBytesFunction · 0.92
oldQuoteBytesFunction · 0.85

Tested by

no test coverage detected