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

Function TestPropertyDeleteIdempotent

property_test.go:454–473  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Property: Delete is idempotent (Delete twice == Delete once) --------------------------------------------------------------------------- reqproof:proptest Delete Verifies: SYS-REQ-034 [property]

(t *testing.T)

Source from the content-addressed store, hash-verified

452// reqproof:proptest Delete
453// Verifies: SYS-REQ-034 [property]
454func TestPropertyDeleteIdempotent(t *testing.T) {
455 r := newRNG(jsonSeed + 6)
456 const iterations = 500
457 for i := 0; i < iterations; i++ {
458 raw, obj := randomObjectJSONBytes(r, 1)
459 var key string
460 for k := range obj {
461 key = k
462 break
463 }
464 if key == "" {
465 continue
466 }
467 once := Delete(raw, key)
468 twice := Delete(once, key)
469 if !bytes.Equal(once, twice) {
470 t.Fatalf("Delete not idempotent on input %q key=%q: once=%q twice=%q", raw, key, once, twice)
471 }
472 }
473}
474
475// ---------------------------------------------------------------------------
476// Property: searchKeys is deterministic and bounded on arbitrary bytes

Callers

nothing calls this directly

Calls 3

newRNGFunction · 0.85
randomObjectJSONBytesFunction · 0.85
DeleteFunction · 0.85

Tested by

no test coverage detected