Index: base/metrics/field_trial_unittest.cc |
=================================================================== |
--- base/metrics/field_trial_unittest.cc (revision 223657) |
+++ base/metrics/field_trial_unittest.cc (working copy) |
@@ -849,4 +849,32 @@ |
EXPECT_EQ(kGroupName, trial->group_name()); |
} |
+TEST_F(FieldTrialTest, FloatBoundariesGiveEqualGroupSizes) { |
+ const int kBucketCount = 100; |
+ |
+ // Try each boundary value |i / 100.0| as the entropy value. |
+ for (int i = 0; i < kBucketCount; ++i) { |
+ const double entropy = i / static_cast<double>(kBucketCount); |
+ |
+ scoped_refptr<base::FieldTrial> trial( |
+ new base::FieldTrial("test", kBucketCount, "default", entropy)); |
+ for (int j = 0; j < kBucketCount; ++j) |
+ trial->AppendGroup(base::StringPrintf("%d", j), 1); |
+ |
+ EXPECT_EQ(base::StringPrintf("%d", i), trial->group_name()); |
+ } |
+} |
+ |
+TEST_F(FieldTrialTest, DoesNotSurpassTotalProbability) { |
+ const double kEntropyValue = 1.0 - 1e-9; |
+ ASSERT_LT(kEntropyValue, 1.0); |
+ |
+ scoped_refptr<base::FieldTrial> trial( |
+ new base::FieldTrial("test", 2, "default", kEntropyValue)); |
+ trial->AppendGroup("1", 1); |
+ trial->AppendGroup("2", 1); |
+ |
+ EXPECT_EQ("2", trial->group_name()); |
+} |
+ |
} // namespace base |