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

Function TestSetCreatesMissingEntryInExistingArray

set_spec_test.go:38–52  ·  view source on GitHub ↗

Verifies: SYS-REQ-009 [boundary] MCDC SYS-REQ-009: set_creates_missing_path=T, set_path_is_provided=T, set_returns_not_found_error=F, set_returns_updated_document=F, set_target_exists=F => TRUE

(t *testing.T)

Source from the content-addressed store, hash-verified

36// Verifies: SYS-REQ-009 [boundary]
37// MCDC SYS-REQ-009: set_creates_missing_path=T, set_path_is_provided=T, set_returns_not_found_error=F, set_returns_updated_document=F, set_target_exists=F => TRUE
38func TestSetCreatesMissingEntryInExistingArray(t *testing.T) {
39 value, err := Set(
40 []byte(`{"top":[{"middle":[{"present":true}]}]}`),
41 []byte(`{"bottom":"value"}`),
42 "top", "[0]", "middle", "[1]",
43 )
44 if err != nil {
45 t.Fatalf("Set returned error: %v", err)
46 }
47
48 expected := `{"top":[{"middle":[{"present":true},{"bottom":"value"}]}]}`
49 if string(value) != expected {
50 t.Fatalf("Set result mismatch: expected %s, got %s", expected, string(value))
51 }
52}
53
54// Verifies: SYS-REQ-009 [fuzz]
55// MCDC SYS-REQ-009: N/A

Callers

nothing calls this directly

Calls 1

SetFunction · 0.85

Tested by

no test coverage detected