Browse Source

add small test case, fix Makefile

master
wes 7 years ago
parent
commit
39e03bbc26
  1. 2
      Makefile
  2. 11
      bfilter.py

2
Makefile

@ -2,5 +2,5 @@ default:
$(MAKE) lib
lib: bfilter.c bfilter.h
$(CC) -g -DLIB -c -fpic -Wall -Wextra -pedantic -Wpointer-arith -Werror -std=c99 -lfnv -lm -L. -O3 ./bfilter.c -Wl,-rpath,/;
$(CC) -g -DLIB -c -fpic -Wall -Wextra -pedantic -Wpointer-arith -std=c99 -lfnv -lm -L. -O3 ./bfilter.c -Wl,-rpath./;
$(CC) -shared -o bfilter.so bfilter.o;

11
bfilter.py

@ -61,3 +61,14 @@ class BloomFilter:
def __getitem__(self, key):
return lib.bfilter_get(self.bitset, key.encode("UTF-8"), self.k) == 1
if __name__ == "__main__":
test = BloomFilter()
print(test)
test.add("one")
test.add("two")
test.add("three")
assert test["three"]
assert not test["four"]

Loading…
Cancel
Save