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

Function TestRemoval4_EachKey_SkipNestedObject

dead_code_audit_test.go:288–310  ·  view source on GitHub ↗

============================================================================= REMOVAL 4: `data[i] == '{'` block removed in EachKey Test: unmatched key followed by nested object must still be skipped. ============================================================================= Verifies: SYS-REQ-008

(t *testing.T)

Source from the content-addressed store, hash-verified

286
287// Verifies: SYS-REQ-008 [boundary]
288func TestRemoval4_EachKey_SkipNestedObject(t *testing.T) {
289 data := []byte(`{"skip":{"nested":"deep"},"want":"found"}`)
290 paths := [][]string{{"want"}}
291
292 var foundValue []byte
293 var foundType ValueType
294 EachKey(data, func(idx int, value []byte, vt ValueType, err error) {
295 if idx == 0 {
296 foundValue = value
297 foundType = vt
298 }
299 }, paths...)
300
301 if foundValue == nil {
302 t.Fatal("UNSAFE: EachKey failed to find 'want' after skipping nested object")
303 }
304 if string(foundValue) != "found" {
305 t.Fatalf("expected 'found', got %q", foundValue)
306 }
307 if foundType != String {
308 t.Fatalf("expected String type, got %v", foundType)
309 }
310}
311
312// Verifies: SYS-REQ-008 [boundary]
313func TestRemoval4_EachKey_SkipDeeplyNestedObject(t *testing.T) {

Callers

nothing calls this directly

Calls 1

EachKeyFunction · 0.85

Tested by

no test coverage detected