Index: components/rappor/bloom_filter_unittest.cc |
diff --git a/components/rappor/bloom_filter_unittest.cc b/components/rappor/bloom_filter_unittest.cc |
index 25f965f8402835ea354ea5f5f391a839baa9d456..3523446f8a25eb742b2359115152067a4bc30359 100644 |
--- a/components/rappor/bloom_filter_unittest.cc |
+++ b/components/rappor/bloom_filter_unittest.cc |
@@ -10,45 +10,25 @@ |
namespace rappor { |
TEST(BloomFilterTest, TinyFilter) { |
- BloomFilter filter(1u, 4u, 0u); |
- |
- // Size is 1 and it's initially empty |
- EXPECT_EQ(1u, filter.bytes().size()); |
- EXPECT_EQ(0x00, filter.bytes()[0]); |
+ ByteVector output(2u); |
// "Test" has a self-collision, and only sets 3 bits. |
- filter.SetString("Test"); |
- EXPECT_EQ(0x2a, filter.bytes()[0]); |
- |
- // Setting the same value shouldn't change anything. |
- filter.SetString("Test"); |
- EXPECT_EQ(0x2a, filter.bytes()[0]); |
- |
- BloomFilter filter2(1u, 4u, 0u); |
- EXPECT_EQ(0x00, filter2.bytes()[0]); |
- filter2.SetString("Bar"); |
- EXPECT_EQ(0xa8, filter2.bytes()[0]); |
+ internal::SetBloomBits(1u, 4u, 0u, "Test", &output); |
+ EXPECT_EQ(0x2a, output[0]); |
+ EXPECT_EQ(0x0, output[1]); |
// The new string should replace the old one. |
- filter.SetString("Bar"); |
- EXPECT_EQ(0xa8, filter.bytes()[0]); |
+ internal::SetBloomBits(1u, 4u, 0u, "Bar", &output); |
+ EXPECT_EQ(0xa8, output[0]); |
+ EXPECT_EQ(0x0, output[1]); |
} |
TEST(BloomFilterTest, HugeFilter) { |
// Create a 500 bit filter, and use a large seed offset to see if anything |
// breaks. |
- BloomFilter filter(500u, 1u, 0xabdef123); |
- |
- // Size is 500 and it's initially empty |
- EXPECT_EQ(500u, filter.bytes().size()); |
- EXPECT_EQ(0, CountBits(filter.bytes())); |
- |
- filter.SetString("Bar"); |
- EXPECT_EQ(1, CountBits(filter.bytes())); |
- |
- // Adding the same value shouldn't change anything. |
- filter.SetString("Bar"); |
- EXPECT_EQ(1, CountBits(filter.bytes())); |
+ ByteVector output(500u); |
+ internal::SetBloomBits(500u, 1u, 0xabdef123, "Bar", &output); |
+ EXPECT_EQ(1, CountBits(output)); |
} |
} // namespace rappor |