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

Side by Side Diff: components/rappor/rappor_metric_unittest.cc

Issue 264123004: Modify rappor parameters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/rappor/rappor_metric.h" 5 #include "components/rappor/rappor_metric.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace rappor { 13 namespace rappor {
14 14
15 const RapporParameters kTestRapporParameters = { 15 const RapporParameters kTestRapporParameters = {
16 1 /* Num cohorts */,
16 16 /* Bloom filter size bytes */, 17 16 /* Bloom filter size bytes */,
17 4 /* Bloom filter hash count */, 18 4 /* Bloom filter hash count */,
18 PROBABILITY_75 /* Fake data probability */, 19 PROBABILITY_75 /* Fake data probability */,
19 PROBABILITY_50 /* Fake one probability */, 20 PROBABILITY_50 /* Fake one probability */,
20 PROBABILITY_75 /* One coin probability */, 21 PROBABILITY_75 /* One coin probability */,
21 PROBABILITY_50 /* Zero coin probability */}; 22 PROBABILITY_50 /* Zero coin probability */};
22 23
23 const RapporParameters kTestStatsRapporParameters = { 24 const RapporParameters kTestStatsRapporParameters = {
25 1 /* Num cohorts */,
24 50 /* Bloom filter size bytes */, 26 50 /* Bloom filter size bytes */,
25 4 /* Bloom filter hash count */, 27 4 /* Bloom filter hash count */,
26 PROBABILITY_75 /* Fake data probability */, 28 PROBABILITY_75 /* Fake data probability */,
27 PROBABILITY_50 /* Fake one probability */, 29 PROBABILITY_50 /* Fake one probability */,
28 PROBABILITY_75 /* One coin probability */, 30 PROBABILITY_75 /* One coin probability */,
29 PROBABILITY_50 /* Zero coin probability */}; 31 PROBABILITY_50 /* Zero coin probability */};
30 32
31 // Check for basic syntax and use. 33 // Check for basic syntax and use.
32 TEST(RapporMetricTest, BasicMetric) { 34 TEST(RapporMetricTest, BasicMetric) {
33 RapporMetric testMetric("MyRappor", kTestRapporParameters, 0); 35 RapporMetric testMetric("MyRappor", kTestRapporParameters, 0);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // stats.binom(152, 0.65625).ppf(0.999995) = 124 89 // stats.binom(152, 0.65625).ppf(0.999995) = 124
88 EXPECT_LE(true_from_true_count, 124); 90 EXPECT_LE(true_from_true_count, 124);
89 91
90 // stats.binom(248, 0.59375).ppf(.000005) = 113 92 // stats.binom(248, 0.59375).ppf(.000005) = 113
91 EXPECT_GT(true_from_false_count, 113); 93 EXPECT_GT(true_from_false_count, 113);
92 // stats.binom(248, 0.59375).ppf(.999995) = 181 94 // stats.binom(248, 0.59375).ppf(.999995) = 181
93 EXPECT_LE(true_from_false_count, 181); 95 EXPECT_LE(true_from_false_count, 181);
94 } 96 }
95 97
96 } // namespace rappor 98 } // namespace rappor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698