MCPcopy
hub / github.com/buger/jsonparser / TestBlockEndSentinel

Function TestBlockEndSentinel

deep_spec_test.go:159–177  ·  view source on GitHub ↗

Verifies: SYS-REQ-046 [boundary] blockEnd returns -1 when no matching closing bracket/brace found.

(t *testing.T)

Source from the content-addressed store, hash-verified

157// Verifies: SYS-REQ-046 [boundary]
158// blockEnd returns -1 when no matching closing bracket/brace found.
159func TestBlockEndSentinel(t *testing.T) {
160 // Unclosed array
161 end := blockEnd([]byte(`[1,2`), '[', ']')
162 if end != -1 {
163 t.Fatalf("blockEnd(unclosed array) = %d, want -1", end)
164 }
165
166 // Unclosed object
167 end2 := blockEnd([]byte(`{"a":1`), '{', '}')
168 if end2 != -1 {
169 t.Fatalf("blockEnd(unclosed object) = %d, want -1", end2)
170 }
171
172 // Properly closed
173 end3 := blockEnd([]byte(`[1,2]`), '[', ']')
174 if end3 < 0 {
175 t.Fatalf("blockEnd(closed array) = %d, want non-negative", end3)
176 }
177}
178
179// =============================================================================
180// Negative array index (SYS-REQ-047)

Callers

nothing calls this directly

Calls 1

blockEndFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…