Directly exercise the fast-path branches with long inputs that would be expensive under per-byte scanning. Verifies: SYS-REQ-045
(t *testing.T)
| 109 | // expensive under per-byte scanning. |
| 110 | // Verifies: SYS-REQ-045 |
| 111 | func TestStringEnd_FastPath_LongInputs(t *testing.T) { |
| 112 | // 1 KiB of 'a' followed by closing quote — exercises IndexByte SIMD scan. |
| 113 | long := bytes.Repeat([]byte{'a'}, 1024) |
| 114 | longWithQuote := append(append([]byte{}, long...), '"') |
| 115 | gotEnd, gotEsc := stringEnd(longWithQuote) |
| 116 | if gotEnd != 1025 || gotEsc { |
| 117 | t.Fatalf("long no-escape: stringEnd=(%d,%v) want=(1025,false)", gotEnd, gotEsc) |
| 118 | } |
| 119 | |
| 120 | // Long with backslash far after the quote — still fast path. |
| 121 | longLateEscape := append(append([]byte{}, long...), '"', '\\', 'n') |
| 122 | gotEnd, gotEsc = stringEnd(longLateEscape) |
| 123 | if gotEnd != 1025 || gotEsc { |
| 124 | t.Fatalf("long late-escape: stringEnd=(%d,%v) want=(1025,false)", gotEnd, gotEsc) |
| 125 | } |
| 126 | |
| 127 | // Long with backslash BEFORE the quote — slow path; result must still match. |
| 128 | longWithEscape := append(append([]byte{}, long...), '\\', '"') |
| 129 | gotEnd, gotEsc = stringEnd(longWithEscape) |
| 130 | wantEnd, wantEsc := referenceStringEnd(longWithEscape) |
| 131 | if gotEnd != wantEnd || gotEsc != wantEsc { |
| 132 | t.Errorf("long early-escape: stringEnd=(%d,%v) want=(%d,%v)", gotEnd, gotEsc, wantEnd, wantEsc) |
| 133 | } |
| 134 | } |
nothing calls this directly
no test coverage detected