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

Function TestRemoval4_EachKey_NestedObjectWithString

dead_code_audit_test.go:373–391  ·  view source on GitHub ↗

Verifies: SYS-REQ-008 [boundary]

(t *testing.T)

Source from the content-addressed store, hash-verified

371
372// Verifies: SYS-REQ-008 [boundary]
373func TestRemoval4_EachKey_NestedObjectWithString(t *testing.T) {
374 // This tests the case where a string value contains braces
375 data := []byte(`{"skip":"has {braces}","want":"found"}`)
376 paths := [][]string{{"want"}}
377
378 var foundValue []byte
379 EachKey(data, func(idx int, value []byte, vt ValueType, err error) {
380 if idx == 0 {
381 foundValue = value
382 }
383 }, paths...)
384
385 if foundValue == nil {
386 t.Fatal("UNSAFE: EachKey failed to find 'want' after string with braces")
387 }
388 if string(foundValue) != "found" {
389 t.Fatalf("expected 'found', got %q", foundValue)
390 }
391}
392
393// =============================================================================
394// REMOVAL 5: `keys[level][0] != '['` removed in searchKeys

Callers

nothing calls this directly

Calls 1

EachKeyFunction · 0.85

Tested by

no test coverage detected