ArrayEach infinite loop guard: verify o==0 catches all no-progress cases Verifies: SYS-REQ-006 [boundary]
(t *testing.T)
| 86 | // ArrayEach infinite loop guard: verify o==0 catches all no-progress cases |
| 87 | // Verifies: SYS-REQ-006 [boundary] |
| 88 | func TestArrayEach_OOB_MalformedElements(t *testing.T) { |
| 89 | tests := []struct { |
| 90 | name string |
| 91 | json string |
| 92 | }{ |
| 93 | {"bare_comma", `[,]`}, |
| 94 | {"double_comma", `[1,,2]`}, |
| 95 | {"just_bracket", `[`}, |
| 96 | {"bracket_space", `[ `}, |
| 97 | {"unclosed_string", `["abc`}, |
| 98 | } |
| 99 | |
| 100 | for _, tt := range tests { |
| 101 | t.Run(tt.name, func(t *testing.T) { |
| 102 | count := 0 |
| 103 | _, err := ArrayEach([]byte(tt.json), func(value []byte, dataType ValueType, offset int, err error) { |
| 104 | count++ |
| 105 | if count > 100 { |
| 106 | t.Fatal("possible infinite loop detected") |
| 107 | } |
| 108 | }) |
| 109 | // We don't care whether it errors; we care that it terminates |
| 110 | _ = err |
| 111 | t.Logf("Terminated with count=%d, err=%v", count, err) |
| 112 | }) |
| 113 | } |
| 114 | } |
nothing calls this directly
no test coverage detected