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

Function TestPropertyFindKeyStartDeterminism

property_test.go:618–630  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Property: findKeyStart is deterministic on arbitrary bytes --------------------------------------------------------------------------- reqproof:proptest findKeyStart Verifies: SYS-REQ-001 [property]

(t *testing.T)

Source from the content-addressed store, hash-verified

616// reqproof:proptest findKeyStart
617// Verifies: SYS-REQ-001 [property]
618func TestPropertyFindKeyStartDeterminism(t *testing.T) {
619 r := newRNG(jsonSeed + 8)
620 const iterations = 2000
621 for i := 0; i < iterations; i++ {
622 raw := randomBytes(r, 64)
623 key := randKey(r)
624 aPos, aErr := findKeyStart(raw, key)
625 bPos, bErr := findKeyStart(raw, key)
626 if aPos != bPos || (aErr == nil) != (bErr == nil) {
627 t.Fatalf("findKeyStart non-deterministic on input %q key=%q: (%d,%v) vs (%d,%v)", raw, key, aPos, aErr, bPos, bErr)
628 }
629 }
630}
631
632// ---------------------------------------------------------------------------
633// Property: token-boundary helpers are deterministic and never panic

Callers

nothing calls this directly

Calls 4

newRNGFunction · 0.85
randomBytesFunction · 0.85
randKeyFunction · 0.85
findKeyStartFunction · 0.85

Tested by

no test coverage detected