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

Side by Side Diff: base/metrics/field_trial_unittest.cc

Issue 596103002: Fix more disabled MSVC warnings, base/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/metrics/field_trial.h" 5 #include "base/metrics/field_trial.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 EXPECT_EQ(trial1.get(), FieldTrialList::Find(name1)); 105 EXPECT_EQ(trial1.get(), FieldTrialList::Find(name1));
106 EXPECT_EQ(trial2.get(), FieldTrialList::Find(name2)); 106 EXPECT_EQ(trial2.get(), FieldTrialList::Find(name2));
107 // Note: FieldTrialList should delete the objects at shutdown. 107 // Note: FieldTrialList should delete the objects at shutdown.
108 } 108 }
109 109
110 TEST_F(FieldTrialTest, AbsoluteProbabilities) { 110 TEST_F(FieldTrialTest, AbsoluteProbabilities) {
111 char always_true[] = " always true"; 111 char always_true[] = " always true";
112 char default_always_true[] = " default always true"; 112 char default_always_true[] = " default always true";
113 char always_false[] = " always false"; 113 char always_false[] = " always false";
114 char default_always_false[] = " default always false"; 114 char default_always_false[] = " default always false";
115 for (int i = 1; i < 250; ++i) { 115 for (char i = 1; i < 250; ++i) {
116 // Try lots of names, by changing the first character of the name. 116 // Try lots of names, by changing the first character of the name.
117 always_true[0] = i; 117 always_true[0] = i;
118 default_always_true[0] = i; 118 default_always_true[0] = i;
119 always_false[0] = i; 119 always_false[0] = i;
120 default_always_false[0] = i; 120 default_always_false[0] = i;
121 121
122 scoped_refptr<FieldTrial> trial_true = 122 scoped_refptr<FieldTrial> trial_true =
123 CreateFieldTrial(always_true, 10, default_always_true, NULL); 123 CreateFieldTrial(always_true, 10, default_always_true, NULL);
124 const std::string winner = "TheWinner"; 124 const std::string winner = "TheWinner";
125 int winner_group = trial_true->AppendGroup(winner, 10); 125 int winner_group = trial_true->AppendGroup(winner, 10);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } while ((!second_winner || !first_winner) && counter < 100); 182 } while ((!second_winner || !first_winner) && counter < 100);
183 EXPECT_TRUE(second_winner); 183 EXPECT_TRUE(second_winner);
184 EXPECT_TRUE(first_winner); 184 EXPECT_TRUE(first_winner);
185 } 185 }
186 186
187 TEST_F(FieldTrialTest, MiddleProbabilities) { 187 TEST_F(FieldTrialTest, MiddleProbabilities) {
188 char name[] = " same name"; 188 char name[] = " same name";
189 char default_group_name[] = " default same name"; 189 char default_group_name[] = " default same name";
190 bool false_event_seen = false; 190 bool false_event_seen = false;
191 bool true_event_seen = false; 191 bool true_event_seen = false;
192 for (int i = 1; i < 250; ++i) { 192 for (char i = 1; i < 250; ++i) {
193 name[0] = i; 193 name[0] = i;
194 default_group_name[0] = i; 194 default_group_name[0] = i;
195 scoped_refptr<FieldTrial> trial = 195 scoped_refptr<FieldTrial> trial =
196 CreateFieldTrial(name, 10, default_group_name, NULL); 196 CreateFieldTrial(name, 10, default_group_name, NULL);
197 int might_win = trial->AppendGroup("MightWin", 5); 197 int might_win = trial->AppendGroup("MightWin", 5);
198 198
199 if (trial->group() == might_win) { 199 if (trial->group() == might_win) {
200 true_event_seen = true; 200 true_event_seen = true;
201 } else { 201 } else {
202 false_event_seen = true; 202 false_event_seen = true;
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 EXPECT_TRUE(active_groups.empty()); 984 EXPECT_TRUE(active_groups.empty());
985 985
986 // The trial shouldn't be listed in the |StatesToString()| result. 986 // The trial shouldn't be listed in the |StatesToString()| result.
987 std::string states; 987 std::string states;
988 FieldTrialList::StatesToString(&states); 988 FieldTrialList::StatesToString(&states);
989 EXPECT_TRUE(states.empty()); 989 EXPECT_TRUE(states.empty());
990 } 990 }
991 } 991 }
992 992
993 } // namespace base 993 } // namespace base
OLDNEW
« base/logging.h ('K') | « base/logging_win.cc ('k') | base/metrics/histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698