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

Function TestDeleteTruncatedMidStructure

deep_spec_test.go:289–311  ·  view source on GitHub ↗

Verifies: SYS-REQ-056 [malformed] Delete on mid-structure truncation shall return original input and not panic.

(t *testing.T)

Source from the content-addressed store, hash-verified

287// Verifies: SYS-REQ-056 [malformed]
288// Delete on mid-structure truncation shall return original input and not panic.
289func TestDeleteTruncatedMidStructure(t *testing.T) {
290 cases := []struct {
291 name string
292 data string
293 keys []string
294 }{
295 {name: "nested unclosed object", data: `{"a":{"b":1`, keys: []string{"a"}},
296 {name: "nested unclosed array in object", data: `{"a":[{"b":1`, keys: []string{"a"}},
297 }
298 for _, tc := range cases {
299 t.Run(tc.name, func(t *testing.T) {
300 func() {
301 defer func() {
302 if r := recover(); r != nil {
303 t.Fatalf("Delete(%q, %v) panicked: %v", tc.data, tc.keys, r)
304 }
305 }()
306 result := Delete([]byte(tc.data), tc.keys...)
307 _ = result
308 }()
309 })
310 }
311}
312
313// =============================================================================
314// Set truncation and edge cases (SYS-REQ-051, SYS-REQ-068, SYS-REQ-069, SYS-REQ-070)

Callers

nothing calls this directly

Calls 1

DeleteFunction · 0.85

Tested by

no test coverage detected