public void TestDeletableReset() { var d = new DeletableBloomFilter(100, 10, 0.1); for (int i = 0; i < 1000; i++) { d.Add(Encoding.ASCII.GetBytes(i.ToString())); } var resetF = d.Reset(); Assert.AreSame(d, resetF, "Returned DeletableBloomFilter should be the same instance"); for (uint i = 0; i < d.Buckets.count; i++) { if (d.Buckets.Get(i) != 0) { Assert.Fail("Expected all bits to be unset"); } } for (uint i = 0; i < d.Collisions.count; i++) { if (d.Collisions.Get(i) != 0) { Assert.Fail("Expected all bits to be unset"); } } var count = d.Count(); Assert.AreEqual(0u, count); }
public void TestDeletableCount() { var d = new DeletableBloomFilter(100, 10, 0.1); for (uint i = 0; i < 10; i++) { d.Add(Encoding.ASCII.GetBytes(i.ToString())); } for (int i = 0; i < 5; i++) { d.TestAndRemove(Encoding.ASCII.GetBytes(i.ToString())); } var count = d.Count(); Assert.AreEqual(5u, count); }