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

Function FuzzQuote

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

Source from the content-addressed store, hash-verified

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