From 02f6001bd123214221069feb03f0070b6b5665f2 Mon Sep 17 00:00:00 2001 From: Rich Apodaca Date: Tue, 30 Jun 2009 11:38:28 -0700 Subject: [PATCH] more bloomfilter tests --- .../mx/fingerprint/BloomFilter.java | 2 +- .../mx/test/BloomFilterTest.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/com/metamolecular/mx/fingerprint/BloomFilter.java b/src/com/metamolecular/mx/fingerprint/BloomFilter.java index 01f1814..1b2afc4 100644 --- a/src/com/metamolecular/mx/fingerprint/BloomFilter.java +++ b/src/com/metamolecular/mx/fingerprint/BloomFilter.java @@ -58,7 +58,7 @@ public class BloomFilter implements Set /** * Simplified constructor that sets the number of expected elements equal to - * the number of bits (a standard practice for cheminformatics applications). + * the number of bits. * * @param bitArraySize * The number of bits in the bit array (often called 'm' in the diff --git a/src/com/metamolecular/mx/test/BloomFilterTest.java b/src/com/metamolecular/mx/test/BloomFilterTest.java index f2af5d5..f046b73 100644 --- a/src/com/metamolecular/mx/test/BloomFilterTest.java +++ b/src/com/metamolecular/mx/test/BloomFilterTest.java @@ -90,6 +90,25 @@ public void testItLacksAStringNotIncludedInBulkAdd() assertFalse(filter.contains("CCCCC")); } + + public void testItSetsBitsOnAddingString() + { + doNew(); + + filter.add("Foo"); + + assertFalse(filter.toBitSet().cardinality() == 0); + } + + public void testItClears() + { + doNew(); + + filter.addAll(Arrays.asList("C", "CC", "CCC", "CCCC")); + filter.clear(); + + assertEquals(0, filter.toBitSet().cardinality()); + } public void testItGivesTheExpectedFalsePositiveRate() {