forked from cwtch.im/tapir
25 lines
379 B
Go
25 lines
379 B
Go
package primitives
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
func TestBloomFilter_Insert(t *testing.T) {
|
|
bf := new(BloomFilter)
|
|
bf.Init(256)
|
|
|
|
fp := 0
|
|
for i := 0; i < 256; i++ {
|
|
input := []byte("test" + strconv.Itoa(256+i))
|
|
if bf.Check(input) {
|
|
t.Log("False Positive!")
|
|
fp++
|
|
}
|
|
bf.Insert(input)
|
|
}
|
|
|
|
t.Logf("Num false positives %v %v%%", fp, (float64(fp)/256.0)*100)
|
|
|
|
}
|