Index: components/rappor/rappor_metric_unittest.cc |
diff --git a/components/rappor/rappor_metric_unittest.cc b/components/rappor/rappor_metric_unittest.cc |
index b8e28dd3a71985b27dc3099985b0506e68033c31..07a1651c483af3ca15b9f5f13c28059b4ba147a5 100644 |
--- a/components/rappor/rappor_metric_unittest.cc |
+++ b/components/rappor/rappor_metric_unittest.cc |
@@ -14,8 +14,9 @@ namespace rappor { |
const RapporParameters kTestRapporParameters = { |
1 /* Num cohorts */, |
- 16 /* Bloom filter size bytes */, |
- 4 /* Bloom filter hash count */, |
+ 4 /* Bloom filter size bytes */, |
+ 2 /* Bloom filter hash count */, |
+ 4, /* Flag bytes */ |
PROBABILITY_75 /* Fake data probability */, |
PROBABILITY_50 /* Fake one probability */, |
PROBABILITY_75 /* One coin probability */, |
@@ -26,36 +27,37 @@ const RapporParameters kTestStatsRapporParameters = { |
1 /* Num cohorts */, |
50 /* Bloom filter size bytes */, |
4 /* Bloom filter hash count */, |
+ 0, /* Flag bytes */ |
PROBABILITY_75 /* Fake data probability */, |
PROBABILITY_50 /* Fake one probability */, |
PROBABILITY_75 /* One coin probability */, |
PROBABILITY_50 /* Zero coin probability */, |
FINE_LEVEL /* Reporting level (not used) */}; |
-// Check for basic syntax and use. |
-TEST(RapporMetricTest, BasicMetric) { |
- RapporMetric testMetric("MyRappor", kTestRapporParameters, 0); |
- testMetric.AddSample("Bar"); |
- EXPECT_EQ(0x80, testMetric.bytes()[1]); |
+TEST(RapporMetricTest, SetSampleBits) { |
+ internal::Sample sample; |
+ internal::SetSampleBits(kTestRapporParameters, 0, "Foo", 0x12, &sample); |
+ EXPECT_EQ(8u, sample.size()); |
+ EXPECT_EQ(0x12, sample[4]); |
} |
TEST(RapporMetricTest, GetReport) { |
- RapporMetric metric("MyRappor", kTestRapporParameters, 0); |
+ internal::RapporMetric metric("MyRappor", kTestRapporParameters); |
const ByteVector report = metric.GetReport( |
HmacByteVectorGenerator::GenerateEntropyInput()); |
- EXPECT_EQ(16u, report.size()); |
+ EXPECT_EQ(8u, report.size()); |
} |
TEST(RapporMetricTest, GetReportStatistics) { |
- RapporMetric metric("MyStatsRappor", kTestStatsRapporParameters, 0); |
+ internal::RapporMetric metric("MyStatsRappor", kTestStatsRapporParameters); |
ByteVector real_bits(kTestStatsRapporParameters.bloom_filter_size_bytes); |
// Set 152 bits (19 bytes) |
for (char i = 0; i < 19; i++) { |
real_bits[i] = 0xff; |
} |
- metric.SetBytesForTesting(real_bits); |
+ metric.AddSample(real_bits); |
const int real_bit_count = CountBits(real_bits); |
EXPECT_EQ(real_bit_count, 152); |