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

Function TestSetIdempotency

obligation_property_test.go:252–272  ·  view source on GitHub ↗

Verifies: SYS-REQ-100 MCDC SYS-REQ-100: set_applied_twice_with_same_args=T, set_second_call_produces_same_result=T => TRUE

(t *testing.T)

Source from the content-addressed store, hash-verified

250// Verifies: SYS-REQ-100
251// MCDC SYS-REQ-100: set_applied_twice_with_same_args=T, set_second_call_produces_same_result=T => TRUE
252func TestSetIdempotency(t *testing.T) {
253 data := []byte(`{"name":"alice","age":30}`)
254 setValue := []byte(`"bob"`)
255
256 // First Set application
257 result1, err1 := Set(data, setValue, "name")
258 if err1 != nil {
259 t.Fatalf("First Set returned error: %v", err1)
260 }
261
262 // Second Set application on the result of the first
263 result2, err2 := Set(result1, setValue, "name")
264 if err2 != nil {
265 t.Fatalf("Second Set returned error: %v", err2)
266 }
267
268 // The results should be identical -- setting the same key to the same value twice
269 if !bytes.Equal(result1, result2) {
270 t.Fatalf("Set not idempotent: first %q, second %q", result1, result2)
271 }
272}
273
274// =============================================================================
275// Nil safety tests

Callers

nothing calls this directly

Calls 1

SetFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…