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

Function TestReaderParserMalformed

reader_parser_test.go:167–177  ·  view source on GitHub ↗

Verifies: SYS-REQ-116 (malformed and truncated streams) SYS-REQ-116:malformed_input:nominal reqproof:proptest:skip targeted malformed-stream witness

(t *testing.T)

Source from the content-addressed store, hash-verified

165// SYS-REQ-116:malformed_input:nominal
166// reqproof:proptest:skip targeted malformed-stream witness
167func TestReaderParserMalformed(t *testing.T) {
168 rp := NewReaderParser(strings.NewReader(`{"message":"unterminated`))
169 if _, _, err := rp.Get("message"); !errors.Is(err, MalformedStringError) {
170 t.Fatalf("truncated string error = %v, want MalformedStringError", err)
171 }
172
173 rp = NewReaderParser(strings.NewReader(`[1,{"open":true}`))
174 if err := rp.ArrayEach(func([]byte, ValueType, error) {}); !errors.Is(err, MalformedArrayError) {
175 t.Fatalf("truncated array error = %v, want MalformedArrayError", err)
176 }
177}
178
179// Verifies: SYS-REQ-116 (tokens crossing read boundaries)
180// SYS-REQ-116:boundary:nominal

Callers

nothing calls this directly

Calls 3

GetMethod · 0.95
ArrayEachMethod · 0.95
NewReaderParserFunction · 0.85

Tested by

no test coverage detected