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

Function TestArrayEach_OOB_MalformedElements

dead_code_audit_oob_test.go:88–114  ·  view source on GitHub ↗

ArrayEach infinite loop guard: verify o==0 catches all no-progress cases Verifies: SYS-REQ-006 [boundary]

(t *testing.T)

Source from the content-addressed store, hash-verified

86// ArrayEach infinite loop guard: verify o==0 catches all no-progress cases
87// Verifies: SYS-REQ-006 [boundary]
88func 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}

Callers

nothing calls this directly

Calls 1

ArrayEachFunction · 0.85

Tested by

no test coverage detected