Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtaco committed Mar 1, 2019
1 parent d8a25ec commit 78b8125
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions go/chat/flip/prng_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,25 @@ func TestPRNGCornerCases(t *testing.T) {
require.NotEqual(t, 0, flips)
require.NotEqual(t, n, flips)
}

// Test the PRNG will cover all values within a given range, if given enough attempts.
func TestPRNGCoverage(t *testing.T) {

test := func(b byte) {
var secret Secret
secret[0] = b
prng := NewPRNG(secret)
n := 32
v := make([]bool, n, n)
for i := 0; i < n*9; i++ {
v[prng.Int(int64(n))] = true
}
for _, e := range v {
require.True(t, e)
}
}

for i := 1; i < 100; i++ {
test(byte(i))
}
}

0 comments on commit 78b8125

Please sign in to comment.