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

Function TestArrayEachTruncatedMidElement

deep_spec_test.go:404–428  ·  view source on GitHub ↗

Verifies: SYS-REQ-053 [malformed] ArrayEach on truncated mid-element shall return error, not panic.

(t *testing.T)

Source from the content-addressed store, hash-verified

402// Verifies: SYS-REQ-053 [malformed]
403// ArrayEach on truncated mid-element shall return error, not panic.
404func TestArrayEachTruncatedMidElement(t *testing.T) {
405 cases := []struct {
406 name string
407 data string
408 }{
409 {name: "truncated object element", data: `[1, {"a":`},
410 {name: "truncated string element", data: `["hello", "world`},
411 {name: "truncated array element", data: `[[1,2`},
412 }
413 for _, tc := range cases {
414 t.Run(tc.name, func(t *testing.T) {
415 func() {
416 defer func() {
417 if r := recover(); r != nil {
418 t.Fatalf("ArrayEach(%q) panicked: %v", tc.data, r)
419 }
420 }()
421 _, err := ArrayEach([]byte(tc.data), func(value []byte, dataType ValueType, offset int, err error) {})
422 if err == nil {
423 t.Logf("ArrayEach(%q) returned no error (may have partial success)", tc.data)
424 }
425 }()
426 })
427 }
428}
429
430// Verifies: SYS-REQ-055 [malformed]
431// ArrayEach with malformed delimiter between elements shall return MalformedArrayError.

Callers

nothing calls this directly

Calls 1

ArrayEachFunction · 0.85

Tested by

no test coverage detected