Пример #1
0
        /// <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));
        }
Пример #2
0
        public static void Add_NonAddedItemIsNotPresent <T>(BaseBloomFilter <T> bf)
        {
            bf.Add("a");

            Assert.IsFalse(bf.IsPresent("b"));
        }
Пример #3
0
 public static void Clear_AddedItemNoLongerPresent <T>(BaseBloomFilter <T> bf)
 {
     bf.Add("a");
     bf.Clear();
     Assert.IsFalse(bf.IsPresent("a"));
 }
Пример #4
0
        public static void Add_AddedItemIsPresent <T>(BaseBloomFilter <T> bf)
        {
            bf.Add("a");

            Assert.IsTrue(bf.IsPresent("a"));
        }
Пример #5
0
 public static void Add_EmptyString_Throws <T>(BaseBloomFilter <T> bf)
 {
     bf.Add(string.Empty);
 }
Пример #6
0
 public static void Add_NullString_Throws <T>(BaseBloomFilter <T> bf)
 {
     bf.Add((string)null);
 }
Пример #7
0
 public static void Add_EmptyData_Throws <T>(BaseBloomFilter <T> bf)
 {
     bf.Add(new byte[0]);
 }
Пример #8
0
 public static void Add_NullData_Throws <T>(BaseBloomFilter <T> bf)
 {
     bf.Add((byte[])null);
 }