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

Function TestRemoval_ObjectEach_MalformedTrailingComma

dead_code_audit_test.go:578–589  ·  view source on GitHub ↗

============================================================================= 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)

Source from the content-addressed store, hash-verified

576
577// Verifies: SYS-REQ-007 [boundary]
578func 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]
592func TestRemoval_ObjectEach_MalformedNoClosingBrace(t *testing.T) {

Callers

nothing calls this directly

Calls 1

ObjectEachFunction · 0.85

Tested by

no test coverage detected