parent
53057c437f
commit
8902c56451
@ -83,3 +83,20 @@ func TestNewLenCharsMaxLength(t *testing.T) {
|
|||||||
chars := make([]byte, 257)
|
chars := make([]byte, 257)
|
||||||
NewLenChars(32, chars)
|
NewLenChars(32, chars)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBias(t *testing.T) {
|
||||||
|
chars := []byte("abcdefghijklmnopqrstuvwxyz")
|
||||||
|
slen := 100000
|
||||||
|
s := NewLenChars(slen, chars)
|
||||||
|
counts := make(map[rune]int)
|
||||||
|
for _, b := range s {
|
||||||
|
counts[b]++
|
||||||
|
}
|
||||||
|
avg := float64(slen) / float64(len(chars))
|
||||||
|
for k, n := range counts {
|
||||||
|
diff := float64(n) / avg
|
||||||
|
if diff < 0.95 || diff > 1.05 {
|
||||||
|
t.Errorf("Bias on '%c': expected average %f, got %d", k, avg, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user