MCPcopy
hub / github.com/buger/jsonparser / TestSetNestedMutation

Function TestSetNestedMutation

deep_spec_test.go:363–377  ·  view source on GitHub ↗

Verifies: SYS-REQ-069 [boundary] Set with multi-level path where intermediate levels exist but leaf does not.

(t *testing.T)

Source from the content-addressed store, hash-verified

361// Verifies: SYS-REQ-069 [boundary]
362// Set with multi-level path where intermediate levels exist but leaf does not.
363func TestSetNestedMutation(t *testing.T) {
364 data := `{"a":{"b":1}}`
365 got, err := Set([]byte(data), []byte(`"newval"`), "a", "c")
366 if err != nil {
367 t.Fatalf("Set nested mutation returned error: %v", err)
368 }
369 // The new key "c" should be created inside "a"
370 val, _, _, err := Get(got, "a", "c")
371 if err != nil {
372 t.Fatalf("Get on Set result failed: %v", err)
373 }
374 if string(val) != "newval" {
375 t.Fatalf("Set nested mutation: got %q, want %q", string(val), "newval")
376 }
377}
378
379// Verifies: SYS-REQ-070 [boundary]
380// Set without any path shall return KeyPathNotFoundError.

Callers

nothing calls this directly

Calls 2

SetFunction · 0.85
GetFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…