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

Function TestDeleteErrorPropagation

deep_spec_test.go:230–256  ·  view source on GitHub ↗

Verifies: SYS-REQ-049 [malformed] Delete where internalGet returns an error shall return original input unchanged.

(t *testing.T)

Source from the content-addressed store, hash-verified

228// Verifies: SYS-REQ-049 [malformed]
229// Delete where internalGet returns an error shall return original input unchanged.
230func TestDeleteErrorPropagation(t *testing.T) {
231 cases := []struct {
232 name string
233 data string
234 keys []string
235 }{
236 {name: "malformed JSON colon chain", data: `{"a"::"b"}`, keys: []string{"a"}},
237 {name: "key not found", data: `{"a":1}`, keys: []string{"missing"}},
238 {name: "empty input", data: ``, keys: []string{"a"}},
239 }
240 for _, tc := range cases {
241 t.Run(tc.name, func(t *testing.T) {
242 func() {
243 defer func() {
244 if r := recover(); r != nil {
245 t.Fatalf("Delete(%q, %v) panicked: %v", tc.data, tc.keys, r)
246 }
247 }()
248 result := Delete([]byte(tc.data), tc.keys...)
249 // Original input should be returned unchanged when error
250 if string(result) != tc.data {
251 t.Logf("Delete(%q, %v) = %q", tc.data, tc.keys, string(result))
252 }
253 }()
254 })
255 }
256}
257
258// Verifies: SYS-REQ-050 [malformed]
259// Delete with array-element path on truncated array input shall return

Callers

nothing calls this directly

Calls 1

DeleteFunction · 0.85

Tested by

no test coverage detected