github.com/parquet-go/parquet-go@v0.20.0/bloom/block_test.go (about) 1 package bloom_test 2 3 import ( 4 "math" 5 "testing" 6 7 "github.com/parquet-go/parquet-go/bloom" 8 ) 9 10 func TestBlock(t *testing.T) { 11 for i := uint64(0); i < math.MaxUint32; i = (i * 2) + 1 { 12 x := uint32(i) 13 b := bloom.Block{} 14 b.Insert(x) 15 if !b.Check(x) { 16 t.Fatalf("bloom filter block does not contain the value that was inserted: %d", x) 17 } 18 if b.Check(x - 1) { 19 t.Fatalf("bloom filter block contains value that was not inserted: %d", ^x) 20 } 21 if b.Check(x + 1) { 22 t.Fatalf("bloom filter block contains value that was not inserted: %d", ^x) 23 } 24 if b.Check(^x) { 25 t.Fatalf("bloom filter block contains value that was not inserted: %d", ^x) 26 } 27 } 28 } 29 30 func BenchmarkBlockInsert(b *testing.B) { 31 x := bloom.Block{} 32 for i := 0; i < b.N; i++ { 33 x.Insert(uint32(i)) 34 } 35 b.SetBytes(bloom.BlockSize) 36 } 37 38 func BenchmarkBlockCheck(b *testing.B) { 39 x := bloom.Block{} 40 x.Insert(42) 41 for i := 0; i < b.N; i++ { 42 x.Check(42) 43 } 44 b.SetBytes(bloom.BlockSize) 45 }