github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/blocks/bloom/filter_test.go (about) 1 package bloom 2 3 import "testing" 4 5 func TestFilter(t *testing.T) { 6 f := BasicFilter() 7 keys := [][]byte{ 8 []byte("hello"), 9 []byte("fish"), 10 []byte("ipfsrocks"), 11 } 12 13 f.Add(keys[0]) 14 if !f.Find(keys[0]) { 15 t.Fatal("Failed to find single inserted key!") 16 } 17 18 f.Add(keys[1]) 19 if !f.Find(keys[1]) { 20 t.Fatal("Failed to find key!") 21 } 22 23 f.Add(keys[2]) 24 25 for _, k := range keys { 26 if !f.Find(k) { 27 t.Fatal("Couldnt find one of three keys") 28 } 29 } 30 }