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

Function TestArrayEachTruncatedAtValueBoundary

deep_spec_test.go:840–865  ·  view source on GitHub ↗

============================================================================= ArrayEach truncated at value boundary (SYS-REQ-083) ============================================================================= Verifies: SYS-REQ-083 [malformed] ArrayEach on truncated-at-value-boundary input shall retur

(t *testing.T)

Source from the content-addressed store, hash-verified

838// Verifies: SYS-REQ-083 [malformed]
839// ArrayEach on truncated-at-value-boundary input shall return error, not panic.
840func TestArrayEachTruncatedAtValueBoundary(t *testing.T) {
841 cases := []struct {
842 name string
843 data string
844 keys []string
845 }{
846 {name: "top level truncated", data: `[1,2`, keys: nil},
847 {name: "nested truncated", data: `{"a":[1,2`, keys: []string{"a"}},
848 {name: "single element no bracket", data: `[1`, keys: nil},
849 }
850 for _, tc := range cases {
851 t.Run(tc.name, func(t *testing.T) {
852 func() {
853 defer func() {
854 if r := recover(); r != nil {
855 t.Fatalf("ArrayEach(%q, %v) panicked: %v", tc.data, tc.keys, r)
856 }
857 }()
858 _, err := ArrayEach([]byte(tc.data), func(value []byte, dataType ValueType, offset int, err error) {}, tc.keys...)
859 if err == nil {
860 t.Logf("ArrayEach(%q, %v) returned no error", tc.data, tc.keys)
861 }
862 }()
863 })
864 }
865}
866
867// =============================================================================
868// ObjectEach truncated mid-structure (SYS-REQ-084)

Callers

nothing calls this directly

Calls 1

ArrayEachFunction · 0.85

Tested by

no test coverage detected