| 22 | ) |
| 23 | |
| 24 | func TestBloom(t *testing.T) { |
| 25 | positive := []string{ |
| 26 | "testtest", |
| 27 | "test", |
| 28 | "hallo", |
| 29 | "other", |
| 30 | } |
| 31 | negative := []string{ |
| 32 | "tes", |
| 33 | "lo", |
| 34 | } |
| 35 | |
| 36 | var bloom Bloom |
| 37 | for _, data := range positive { |
| 38 | bloom.Add(new(big.Int).SetBytes([]byte(data))) |
| 39 | } |
| 40 | |
| 41 | for _, data := range positive { |
| 42 | if !bloom.TestBytes([]byte(data)) { |
| 43 | t.Error("expected", data, "to test true") |
| 44 | } |
| 45 | } |
| 46 | for _, data := range negative { |
| 47 | if bloom.TestBytes([]byte(data)) { |
| 48 | t.Error("did not expect", data, "to test true") |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | import ( |