============================================================================= ObjectEach truncation (SYS-REQ-054) ============================================================================= Verifies: SYS-REQ-054 [malformed] ObjectEach on truncated mid-entry shall return error, not panic.
(t *testing.T)
| 455 | // Verifies: SYS-REQ-054 [malformed] |
| 456 | // ObjectEach on truncated mid-entry shall return error, not panic. |
| 457 | func TestObjectEachTruncatedMidEntry(t *testing.T) { |
| 458 | cases := []struct { |
| 459 | name string |
| 460 | data string |
| 461 | }{ |
| 462 | {name: "truncated second value", data: `{"a":1, "b":`}, |
| 463 | {name: "truncated nested object value", data: `{"a":{"b":1`}, |
| 464 | {name: "truncated string value", data: `{"a":"hello`}, |
| 465 | } |
| 466 | for _, tc := range cases { |
| 467 | t.Run(tc.name, func(t *testing.T) { |
| 468 | func() { |
| 469 | defer func() { |
| 470 | if r := recover(); r != nil { |
| 471 | t.Fatalf("ObjectEach(%q) panicked: %v", tc.data, r) |
| 472 | } |
| 473 | }() |
| 474 | err := ObjectEach([]byte(tc.data), func(key []byte, value []byte, dataType ValueType, offset int) error { |
| 475 | return nil |
| 476 | }) |
| 477 | if err == nil { |
| 478 | t.Logf("ObjectEach(%q) returned no error (partial parse may succeed)", tc.data) |
| 479 | } |
| 480 | }() |
| 481 | }) |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | // ============================================================================= |
| 486 | // ParseBoolean partial literals (SYS-REQ-057) |
nothing calls this directly
no test coverage detected