Verifies: SYS-REQ-029 [malformed_input] SYS-REQ-029:malformed_input:negative SYS-REQ-029:non_array_root_no_callback:negative Negative witness: ArrayEach on a non-array root value (object, number, string, bool) must NOT invoke the callback at all and must return an error. Before this fix, ArrayEach e
(t *testing.T)
| 2537 | // as a string element) before returning MalformedArrayError — a caller |
| 2538 | // performing side effects in the callback observed a bogus invocation. |
| 2539 | func TestArrayEachNonArrayRootNoCallback_SYS029(t *testing.T) { |
| 2540 | cases := []struct { |
| 2541 | name string |
| 2542 | data string |
| 2543 | }{ |
| 2544 | {"object_root", `{"a":1,"b":2}`}, |
| 2545 | {"number_root", `12345`}, |
| 2546 | {"bool_root", `true`}, |
| 2547 | {"null_root", `null`}, |
| 2548 | } |
| 2549 | for _, c := range cases { |
| 2550 | t.Run(c.name, func(t *testing.T) { |
| 2551 | callbacks := 0 |
| 2552 | _, err := ArrayEach([]byte(c.data), func(v []byte, vt ValueType, o int, e error) { |
| 2553 | callbacks++ |
| 2554 | }) |
| 2555 | if err == nil { |
| 2556 | t.Fatalf("ArrayEach(%s) expected error, got nil", c.data) |
| 2557 | } |
| 2558 | if callbacks != 0 { |
| 2559 | t.Fatalf("ArrayEach(%s) emitted %d callback(s) before erroring — non-array root must not invoke callback", c.data, callbacks) |
| 2560 | } |
| 2561 | }) |
| 2562 | } |
| 2563 | } |
nothing calls this directly
no test coverage detected