--------------------------------------------------------------------------- Property: searchKeys is deterministic and bounded on arbitrary bytes --------------------------------------------------------------------------- reqproof:proptest searchKeys Verifies: SYS-REQ-001 [property]
(t *testing.T)
| 479 | // reqproof:proptest searchKeys |
| 480 | // Verifies: SYS-REQ-001 [property] |
| 481 | func TestPropertySearchKeysDeterminism(t *testing.T) { |
| 482 | r := newRNG(jsonSeed + 7) |
| 483 | const iterations = 2000 |
| 484 | for i := 0; i < iterations; i++ { |
| 485 | raw := randomBytes(r, 64) |
| 486 | key := randKey(r) |
| 487 | a := searchKeys(raw, key) |
| 488 | b := searchKeys(raw, key) |
| 489 | if a != b { |
| 490 | t.Fatalf("searchKeys non-deterministic on input %q key=%q: %d vs %d", raw, key, a, b) |
| 491 | } |
| 492 | // Result is either -1 (not found) or a valid index into raw. |
| 493 | if a != -1 && (a < 0 || a >= len(raw)) { |
| 494 | t.Fatalf("searchKeys returned out-of-range index %d on input %q (len=%d)", a, raw, len(raw)) |
| 495 | } |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | // --------------------------------------------------------------------------- |
| 500 | // Property: findKeyStart is deterministic on arbitrary bytes |
nothing calls this directly
no test coverage detected