MCPcopy Create free account
hub / github.com/cel-expr/cel-go / FuzzQuote

Function FuzzQuote

ext/strings_test.go:803–851  ·  view source on GitHub ↗
(f *testing.F)

Source from the content-addressed store, hash-verified

801}
802
803func FuzzQuote(f *testing.F) {
804 tests := []string{
805 "this is a test",
806 `only one quote"`,
807 `"only one quote`,
808 "first\nsecond",
809 "bell\a",
810 "\bbackspace",
811 "\fform feed",
812 "carriage \r return",
813 "horizontal \ttab",
814 "vertical \v tab",
815 "double \\\\ slash",
816 "two escape sequences \a\n",
817 "ends with \\",
818 "\\ starts with",
819 "printable unicode😀",
820 "mid-string \" quote",
821 "\\? and \\`",
822 "filler \x9f",
823 "size('ÿ')",
824 "size('πέντε')",
825 "завтра",
826 "\U0001F431\U0001F600\U0001F61B",
827 "ta©o©αT",
828 }
829 for _, tc := range tests {
830 f.Add(tc)
831 }
832 f.Fuzz(func(t *testing.T, s string) {
833 quoted, err := quote(s)
834 if err != nil {
835 if utf8.ValidString(s) {
836 t.Errorf("unexpected error: %s", err)
837 }
838 } else {
839 unquoted, err := unquote(quoted)
840 if err != nil {
841 t.Errorf("unexpected error: %s", err)
842 } else if s != sanitize(s) {
843 if unquoted != sanitize(s) {
844 t.Errorf("input-output mismatch on test case containing invalid UTF-8: sanitized original: %q, quoted: %q, quote/unquote: %q", sanitize(s), quoted, unquoted)
845 }
846 } else if unquoted != s {
847 t.Errorf("input-output mismatch: original: %q, quoted: %q, quote/unquote: %q", s, quoted, unquoted)
848 }
849 }
850 })
851}
852
853func TestStringCostTracking(t *testing.T) {
854 tests := []struct {

Callers

nothing calls this directly

Calls 4

quoteFunction · 0.85
unquoteFunction · 0.85
sanitizeFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected