/// <summary> /// Tests to make sure the that the requested error rate is achieved /// when inserting random strings. /// </summary> public static void ErrorRateWithinExpectedBounds <T>(BaseBloomFilter <T> bf) { for (int i = 0; i < bf.ExpectedNumberOfElements; i++) { bf.Add(StaticRandom.NextString(10)); } int falsePositives = 0; for (int i = 0; i < bf.ExpectedNumberOfElements; i++) { if (bf.IsPresent(StaticRandom.NextString(5))) { falsePositives++; } } Assert.LessOrEqual(falsePositives, (1.03d * ((double)bf.ExpectedNumberOfElements) * bf.ErrorRate)); }
public static void Add_NonAddedItemIsNotPresent <T>(BaseBloomFilter <T> bf) { bf.Add("a"); Assert.IsFalse(bf.IsPresent("b")); }
public static void Clear_AddedItemNoLongerPresent <T>(BaseBloomFilter <T> bf) { bf.Add("a"); bf.Clear(); Assert.IsFalse(bf.IsPresent("a")); }
public static void Add_AddedItemIsPresent <T>(BaseBloomFilter <T> bf) { bf.Add("a"); Assert.IsTrue(bf.IsPresent("a")); }