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

Unified Diff: components/rappor/rappor_metric_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/rappor_metric.cc ('k') | components/rappor/rappor_parameters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « components/rappor/rappor_metric.cc ('k') | components/rappor/rappor_parameters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698