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

Side by Side Diff: chrome/browser/metrics/perf/random_selector_unittest.cc

Issue 1550593002: Switch to standard integer types in chrome/browser/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/metrics/perf/random_selector.h" 5 #include "chrome/browser/metrics/perf/random_selector.h"
6 6
7 #include <stddef.h>
8
7 #include <cmath> 9 #include <cmath>
8 #include <map> 10 #include <map>
9 #include <string> 11 #include <string>
10 12
13 #include "base/macros.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 15
13 // A small floating point number used to verify that the expected odds are equal 16 // A small floating point number used to verify that the expected odds are equal
14 // to the odds set. 17 // to the odds set.
15 const double kEpsilon = 0.01; 18 const double kEpsilon = 0.01;
16 19
17 // A class that overrides RandDoubleUpTo() to not be random. The number 20 // A class that overrides RandDoubleUpTo() to not be random. The number
18 // generator will emulate a uniform distribution of numbers between 0.0 and 21 // generator will emulate a uniform distribution of numbers between 0.0 and
19 // |max| when called with the same |max| parameter and a whole multiple of 22 // |max| when called with the same |max| parameter and a whole multiple of
20 // |random_period| times. This allows better testing of the RandomSelector 23 // |random_period| times. This allows better testing of the RandomSelector
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 good_odds.push_back(WeightAndValue(2, "b --help")); 138 good_odds.push_back(WeightAndValue(2, "b --help"));
136 good_odds.push_back(WeightAndValue(3, "c bar")); 139 good_odds.push_back(WeightAndValue(3, "c bar"));
137 RandomSelector random_selector; 140 RandomSelector random_selector;
138 EXPECT_TRUE(random_selector.SetOdds(good_odds)); 141 EXPECT_TRUE(random_selector.SetOdds(good_odds));
139 EXPECT_EQ(good_odds, random_selector.odds()); 142 EXPECT_EQ(good_odds, random_selector.odds());
140 143
141 std::vector<RandomSelector::WeightAndValue> empty_odds; 144 std::vector<RandomSelector::WeightAndValue> empty_odds;
142 EXPECT_FALSE(random_selector.SetOdds(empty_odds)); 145 EXPECT_FALSE(random_selector.SetOdds(empty_odds));
143 EXPECT_EQ(good_odds, random_selector.odds()); 146 EXPECT_EQ(good_odds, random_selector.odds());
144 } 147 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/perf/random_selector.h ('k') | chrome/browser/metrics/plugin_metrics_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698