def test_cbf_export_hex(self): """ test the exporting of the bloom filter to a hex string """ h_val = ("01000000000000000300000000000000000000000000000000000000010" "00000000000000200000000000000000000000200000001000000010000" "00020000000000000000000000000000000000000000000000000000000" "10000000000000000000000010000000000000000000000000000000100" "00000100000000000000020000000100000000000000010000000100000" "00100000000000000000000000200000000000000010000000100000000" "00000002000000010000000000000000000000000000000200000000000" "00001000000000000000000000001000000010000000000000000000000" "01000000020000000000000002000000000000000000000a00000000000" "0000a3d4ccccd") blm = CountingBloomFilter(est_elements=10, false_positive_rate=0.05) for i in range(0, 10): tmp = "this is a test {0}".format(i) blm.add(tmp) hex_out = blm.export_hex() self.assertEqual(hex_out, h_val)
def test_cbf_export_hex(self): ''' test the exporting of the bloom filter to a hex string ''' h_val = ('01000000000000000300000000000000000000000000000000000000010' '00000000000000200000000000000000000000200000001000000010000' '00020000000000000000000000000000000000000000000000000000000' '10000000000000000000000010000000000000000000000000000000100' '00000100000000000000020000000100000000000000010000000100000' '00100000000000000000000000200000000000000010000000100000000' '00000002000000010000000000000000000000000000000200000000000' '00001000000000000000000000001000000010000000000000000000000' '01000000020000000000000002000000000000000000000a00000000000' '0000a3d4ccccd') blm = CountingBloomFilter(est_elements=10, false_positive_rate=0.05) for i in range(0, 10): tmp = 'this is a test {0}'.format(i) blm.add(tmp) hex_out = blm.export_hex() self.assertEqual(hex_out, h_val)