Beispiel #1
0
        public void TestScalableBloomReset()
        {
            var f = new ScalableBloomFilter(10, 0.1, 0.8);

            for (int i = 0; i < 1000; i++)
            {
                f.Add(Encoding.ASCII.GetBytes(i.ToString()));
            }

            var count = f.Filters.Count;

            Assert.IsTrue(count > 1, string.Format("Expected more than 1 filter, got {0}", count));

            var resetF = f.Reset();

            Assert.AreSame(f, resetF, "Returned ScalableBloomFilter should be the same instance");

            count = f.Filters.Count;
            Assert.IsTrue(count == 1, string.Format("Expected 1 filter, got {0}", count));

            foreach (var partition in f.Filters[0].Partitions)
            {
                for (uint i = 0; i < partition.count; i++)
                {
                    if (partition.Get(i) != 0)
                    {
                        Assert.Fail("Expected all bits to be unset");
                    }
                }
            }
        }