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

Function TestPropertyFindKeyStartDeterminism

property_test.go:505–517  ·  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

503// reqproof:proptest findKeyStart
504// Verifies: SYS-REQ-001 [property]
505func TestPropertyFindKeyStartDeterminism(t *testing.T) {
506 r := newRNG(jsonSeed + 8)
507 const iterations = 2000
508 for i := 0; i < iterations; i++ {
509 raw := randomBytes(r, 64)
510 key := randKey(r)
511 aPos, aErr := findKeyStart(raw, key)
512 bPos, bErr := findKeyStart(raw, key)
513 if aPos != bPos || (aErr == nil) != (bErr == nil) {
514 t.Fatalf("findKeyStart non-deterministic on input %q key=%q: (%d,%v) vs (%d,%v)", raw, key, aPos, aErr, bPos, bErr)
515 }
516 }
517}
518
519// ---------------------------------------------------------------------------
520// 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