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

Function TestPropertySetRoundTrip

property_test.go:426–446  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Property: Set then Get returns the set value (round-trip) --------------------------------------------------------------------------- reqproof:proptest Set Verifies: SYS-REQ-009 [property]

(t *testing.T)

Source from the content-addressed store, hash-verified

424// reqproof:proptest Set
425// Verifies: SYS-REQ-009 [property]
426func TestPropertySetRoundTrip(t *testing.T) {
427 r := newRNG(jsonSeed + 5)
428 const iterations = 500
429 for i := 0; i < iterations; i++ {
430 // Start from an object (possibly empty) so Set has a target.
431 base := []byte(`{}`)
432 key := randKey(r)
433 setVal := []byte(strconv.FormatInt(r.Int63(), 10))
434 out, err := Set(base, setVal, key)
435 if err != nil {
436 t.Fatalf("Set errored on key=%q val=%q base=%q: %v", key, setVal, base, err)
437 }
438 got, _, _, gerr := Get(out, key)
439 if gerr != nil {
440 t.Fatalf("Set→Get failed to find key=%q in output %q: %v", key, out, gerr)
441 }
442 if !bytes.Equal(got, setVal) {
443 t.Fatalf("Set→Get value mismatch on key=%q: got=%q want=%q (out=%q)", key, got, setVal, out)
444 }
445 }
446}
447
448// ---------------------------------------------------------------------------
449// Property: Delete is idempotent (Delete twice == Delete once)

Callers

nothing calls this directly

Calls 4

newRNGFunction · 0.85
randKeyFunction · 0.85
SetFunction · 0.85
GetFunction · 0.85

Tested by

no test coverage detected