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

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

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « base/message_loop/message_pump_mac.mm ('k') | base/metrics/histogram.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/build_time.h" 7 #include "base/build_time.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 TEST_F(FieldTrialTest, FloatBoundariesGiveEqualGroupSizes) { 1014 TEST_F(FieldTrialTest, FloatBoundariesGiveEqualGroupSizes) {
1015 const int kBucketCount = 100; 1015 const int kBucketCount = 100;
1016 1016
1017 // Try each boundary value |i / 100.0| as the entropy value. 1017 // Try each boundary value |i / 100.0| as the entropy value.
1018 for (int i = 0; i < kBucketCount; ++i) { 1018 for (int i = 0; i < kBucketCount; ++i) {
1019 const double entropy = i / static_cast<double>(kBucketCount); 1019 const double entropy = i / static_cast<double>(kBucketCount);
1020 1020
1021 scoped_refptr<base::FieldTrial> trial( 1021 scoped_refptr<base::FieldTrial> trial(
1022 new base::FieldTrial("test", kBucketCount, "default", entropy)); 1022 new base::FieldTrial("test", kBucketCount, "default", entropy));
1023 for (int j = 0; j < kBucketCount; ++j) 1023 for (int j = 0; j < kBucketCount; ++j)
1024 trial->AppendGroup(base::StringPrintf("%d", j), 1); 1024 trial->AppendGroup(base::IntToString(j), 1);
1025 1025
1026 EXPECT_EQ(base::StringPrintf("%d", i), trial->group_name()); 1026 EXPECT_EQ(base::IntToString(i), trial->group_name());
1027 } 1027 }
1028 } 1028 }
1029 1029
1030 TEST_F(FieldTrialTest, DoesNotSurpassTotalProbability) { 1030 TEST_F(FieldTrialTest, DoesNotSurpassTotalProbability) {
1031 const double kEntropyValue = 1.0 - 1e-9; 1031 const double kEntropyValue = 1.0 - 1e-9;
1032 ASSERT_LT(kEntropyValue, 1.0); 1032 ASSERT_LT(kEntropyValue, 1.0);
1033 1033
1034 scoped_refptr<base::FieldTrial> trial( 1034 scoped_refptr<base::FieldTrial> trial(
1035 new base::FieldTrial("test", 2, "default", kEntropyValue)); 1035 new base::FieldTrial("test", 2, "default", kEntropyValue));
1036 trial->AppendGroup("1", 1); 1036 trial->AppendGroup("1", 1);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 // Trying to instantiate a one-time randomized field trial before the 1124 // Trying to instantiate a one-time randomized field trial before the
1125 // FieldTrialList is created should crash. 1125 // FieldTrialList is created should crash.
1126 EXPECT_DEATH(FieldTrialList::FactoryGetFieldTrial( 1126 EXPECT_DEATH(FieldTrialList::FactoryGetFieldTrial(
1127 "OneTimeRandomizedTrialWithoutFieldTrialList", 100, kDefaultGroupName, 1127 "OneTimeRandomizedTrialWithoutFieldTrialList", 100, kDefaultGroupName,
1128 base::FieldTrialList::kNoExpirationYear, 1, 1, 1128 base::FieldTrialList::kNoExpirationYear, 1, 1,
1129 base::FieldTrial::ONE_TIME_RANDOMIZED, NULL), ""); 1129 base::FieldTrial::ONE_TIME_RANDOMIZED, NULL), "");
1130 } 1130 }
1131 #endif 1131 #endif
1132 1132
1133 } // namespace base 1133 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_mac.mm ('k') | base/metrics/histogram.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698