Verifies: SYS-REQ-045
(t *testing.T)
| 51 | |
| 52 | // Verifies: SYS-REQ-045 |
| 53 | func 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 |
| 82 | func TestStringEnd_FastPathEquivalence_Random(t *testing.T) { |
nothing calls this directly
no test coverage detected