MCPcopy Create free account
hub / github.com/segmentio/encoding / TestParseStringUnquote

Function TestParseStringUnquote

json/parse_test.go:58–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestParseStringUnquote(t *testing.T) {
59 tests := []struct {
60 in string
61 out string
62 ext string
63 }{
64 {`""`, ``, ``},
65 {`"1234567890"`, `1234567890`, ``},
66 {`"Hello World!"`, `Hello World!`, ``},
67 {`"Hello\"World!"`, `Hello"World!`, ``},
68 {`"\\"`, `\`, ``},
69 {`"\u0061\u0062\u0063"`, `abc`, ``},
70 }
71
72 d := decoder{}
73 for _, test := range tests {
74 t.Run(test.in, func(t *testing.T) {
75 out, ext, _, err := d.parseStringUnquote([]byte(test.in), nil)
76 if err != nil {
77 t.Errorf("%s => %s", test.in, err)
78 return
79 }
80
81 if s := string(out); s != test.out {
82 t.Error("invalid output")
83 t.Logf("expected: %s", test.out)
84 t.Logf("found: %s", s)
85 }
86
87 if s := string(ext); s != test.ext {
88 t.Error("invalid extra bytes")
89 t.Logf("expected: %s", test.ext)
90 t.Logf("found: %s", s)
91 }
92 })
93 }
94}
95
96func TestAppendToLower(t *testing.T) {
97 tests := []string{

Callers

nothing calls this directly

Calls 2

parseStringUnquoteMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…