Exemple #1
0
        public void FillRatio_WithOneItem_ShouldBeNumHashesDividedByBitArraySize()
        {
            var filter = new MyTestBloomFilter <int>(250, 3);

            filter.Add(42);
            Assert.Equal(3d / 250d, filter.FillRatio);
        }
Exemple #2
0
 public Property FillRatio_WithOneItem_ShouldBeNumHashesDevidedByBitArraySize_Prop()
 {
     return(Prop.ForAll(Arb.From(Gen.Choose(1, 10000)), Arb.From(Gen.Choose(1, 99)), (bitArraySize, numHashes) =>
     {
         var filter = new MyTestBloomFilter <int>(bitArraySize, numHashes, ByteConverter);
         filter.Add(42);
         (numHashes / (double)bitArraySize == filter.FillRatio).ToProperty();
     }));
 }
 public Property FillRatio_WithOneItem_ShouldBeNumHashesDividedByBitArraySize()
 {
     return(Prop.ForAll(Arb.Default.Int32(), Arb.From(Gen.Choose(1, 10000)), Arb.From(Gen.Choose(1, 99)), (testData, bitArraySize, errorRate) =>
     {
         var realErrorRate = (int)(errorRate / 100d);
         var filter = new MyTestBloomFilter <int>(bitArraySize, realErrorRate, ByteConverter);
         filter.Add(testData);
         return (realErrorRate / bitArraySize == filter.FillRatio).ToProperty();
     }));
 }