============================================================================= EXTRA: ObjectEach `for offset < len(data)` → `for {}` Verify the loop can't run past the end of data. ============================================================================= Verifies: SYS-REQ-007 [boundary]
(t *testing.T)
| 576 | |
| 577 | // Verifies: SYS-REQ-007 [boundary] |
| 578 | func TestRemoval_ObjectEach_MalformedTrailingComma(t *testing.T) { |
| 579 | // Object ends with comma but no more entries: `{"a":1,}` |
| 580 | // After parsing "a":1, the loop finds comma, skips it, calls nextToken. |
| 581 | // nextToken on "}" returns 0, offset points to '}', loop iteration starts, |
| 582 | // switch hits '}' → return nil. No out-of-bounds. |
| 583 | err := ObjectEach([]byte(`{"a":1,"b":2}`), func(key []byte, value []byte, dataType ValueType, offset int) error { |
| 584 | return nil |
| 585 | }) |
| 586 | if err != nil { |
| 587 | t.Fatalf("unexpected error: %v", err) |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | // Verifies: SYS-REQ-007 [boundary] |
| 592 | func TestRemoval_ObjectEach_MalformedNoClosingBrace(t *testing.T) { |
nothing calls this directly
no test coverage detected