Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: components/rappor/bloom_filter_unittest.cc

Issue 1058333002: Multi-dimension rappor metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and add xml support Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/rappor/bloom_filter.cc ('k') | components/rappor/rappor_metric.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « components/rappor/bloom_filter.cc ('k') | components/rappor/rappor_metric.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698