============================================================================= 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)
| 286 | |
| 287 | // Verifies: SYS-REQ-008 [boundary] |
| 288 | func 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] |
| 313 | func TestRemoval4_EachKey_SkipDeeplyNestedObject(t *testing.T) { |