Verifies: SYS-REQ-008 [boundary] Code MC/DC gap: parser.go:491 EachKey data[i] == '{' Drive data[i] == '{' to FALSE after an unmatched key. This happens when the value after an unmatched key is NOT an object (e.g., a number, string, array, or boolean).
(t *testing.T)
| 568 | // the value after an unmatched key is NOT an object (e.g., a number, string, |
| 569 | // array, or boolean). |
| 570 | func TestCodeMCDC_EachKeyNonObjectUnmatchedValue(t *testing.T) { |
| 571 | // The key "skip" has a number value (not '{'), so data[i] == '{' is FALSE. |
| 572 | var found bool |
| 573 | EachKey([]byte(`{"skip":123,"want":"yes"}`), func(idx int, value []byte, vt ValueType, err error) { |
| 574 | if string(value) == "yes" { |
| 575 | found = true |
| 576 | } |
| 577 | }, []string{"want"}) |
| 578 | if !found { |
| 579 | t.Fatal("EachKey should find 'want' after skipping non-object value") |
| 580 | } |
| 581 | |
| 582 | // Also test with array value (not '{') |
| 583 | var found2 bool |
| 584 | EachKey([]byte(`{"skip":[1,2],"want":"yes"}`), func(idx int, value []byte, vt ValueType, err error) { |
| 585 | if string(value) == "yes" { |
| 586 | found2 = true |
| 587 | } |
| 588 | }, []string{"want"}) |
| 589 | if !found2 { |
| 590 | t.Fatal("EachKey should find 'want' after skipping array value") |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | // Verifies: SYS-REQ-001 [boundary] |
| 595 | // Code MC/DC gap: parser.go:945 getType end == -1 |