Verifies: SYS-REQ-053 [malformed] ArrayEach on truncated mid-element shall return error, not panic.
(t *testing.T)
| 402 | // Verifies: SYS-REQ-053 [malformed] |
| 403 | // ArrayEach on truncated mid-element shall return error, not panic. |
| 404 | func TestArrayEachTruncatedMidElement(t *testing.T) { |
| 405 | cases := []struct { |
| 406 | name string |
| 407 | data string |
| 408 | }{ |
| 409 | {name: "truncated object element", data: `[1, {"a":`}, |
| 410 | {name: "truncated string element", data: `["hello", "world`}, |
| 411 | {name: "truncated array element", data: `[[1,2`}, |
| 412 | } |
| 413 | for _, tc := range cases { |
| 414 | t.Run(tc.name, func(t *testing.T) { |
| 415 | func() { |
| 416 | defer func() { |
| 417 | if r := recover(); r != nil { |
| 418 | t.Fatalf("ArrayEach(%q) panicked: %v", tc.data, r) |
| 419 | } |
| 420 | }() |
| 421 | _, err := ArrayEach([]byte(tc.data), func(value []byte, dataType ValueType, offset int, err error) {}) |
| 422 | if err == nil { |
| 423 | t.Logf("ArrayEach(%q) returned no error (may have partial success)", tc.data) |
| 424 | } |
| 425 | }() |
| 426 | }) |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | // Verifies: SYS-REQ-055 [malformed] |
| 431 | // ArrayEach with malformed delimiter between elements shall return MalformedArrayError. |
nothing calls this directly
no test coverage detected