MCPcopy Create free account
hub / github.com/buger/jsonparser / TestStringEnd_FastPathEquivalence_Cases

Function TestStringEnd_FastPathEquivalence_Cases

optimization_equiv_test.go:53–79  ·  view source on GitHub ↗

Verifies: SYS-REQ-045

(t *testing.T)

Source from the content-addressed store, hash-verified

51
52// Verifies: SYS-REQ-045
53func TestStringEnd_FastPathEquivalence_Cases(t *testing.T) {
54 cases := [][]byte{
55 {}, // empty
56 []byte(`hello`), // no '"' no '\' -> (-1, false)
57 []byte(`he\llo`), // '\' no '"' -> (-1, true)
58 []byte(`hello"`), // '"' no '\' -> (6, false)
59 []byte(`a\"b"`), // '\' then '"' -> slow path, escaped
60 []byte(`a\\"b"`), // '\\' then '"' -> slow path, unescaped
61 []byte(`a\\\"b"`), // '\\\' then '"' -> slow path, escaped
62 []byte(`"`), // lone quote
63 []byte(`\`), // lone backslash
64 []byte(`\"`), // '\' then '"' (escaped quote, no terminator)
65 []byte(`""`), // two unescaped quotes — should return at first
66 []byte(`a"b"c"`), // first quote wins
67 []byte(`a\""b"`), // escaped then unescaped
68 []byte(`a\\\"\\\\"`), // complex escape mix ending unescaped
69 []byte(`\u00e9"`), // unicode escape, common
70 }
71 for i, in := range cases {
72 gotEnd, gotEsc := stringEnd(in)
73 wantEnd, wantEsc := referenceStringEnd(in)
74 if gotEnd != wantEnd || gotEsc != wantEsc {
75 t.Errorf("case %d (%q): stringEnd=(%d,%v) want=(%d,%v)",
76 i, in, gotEnd, gotEsc, wantEnd, wantEsc)
77 }
78 }
79}
80
81// Verifies: SYS-REQ-045
82func TestStringEnd_FastPathEquivalence_Random(t *testing.T) {

Callers

nothing calls this directly

Calls 2

stringEndFunction · 0.85
referenceStringEndFunction · 0.85

Tested by

no test coverage detected