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

Function TestAppendDoesNotMutateInput

append_test.go:131–145  ·  view source on GitHub ↗

Verifies: SYS-REQ-110 (Set/array append) reqproof:proptest:skip

(t *testing.T)

Source from the content-addressed store, hash-verified

129// Verifies: SYS-REQ-110 (Set/array append)
130// reqproof:proptest:skip
131func TestAppendDoesNotMutateInput(t *testing.T) {
132 input := []byte(`{"items":[1,2]}`)
133 original := bytes.Clone(input)
134
135 got, err := Append(input, []byte(`3`), "items")
136 if err != nil {
137 t.Fatalf("Append returned error: %v", err)
138 }
139 if !bytes.Equal(input, original) {
140 t.Fatalf("Append mutated input: got %s, want %s", input, original)
141 }
142 if want := `{"items":[1,2,3]}`; string(got) != want {
143 t.Fatalf("Append result = %s, want %s", got, want)
144 }
145}

Callers

nothing calls this directly

Calls 1

AppendFunction · 0.85

Tested by

no test coverage detected