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

Side by Side Diff: chrome/common/variations/experiment_labels_unittest.cc

Issue 641363003: Convert ARRAYSIZE_UNSAFE -> arraysize in chrome/, outside of chrome/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 "chrome/common/variations/experiment_labels.h" 5 #include "chrome/common/variations/experiment_labels.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // Register a few VariationIDs. 47 // Register a few VariationIDs.
48 AssociateGoogleVariationID(variations::GOOGLE_UPDATE_SERVICE, "FieldTrialA", 48 AssociateGoogleVariationID(variations::GOOGLE_UPDATE_SERVICE, "FieldTrialA",
49 "Default", TEST_VALUE_A); 49 "Default", TEST_VALUE_A);
50 AssociateGoogleVariationID(variations::GOOGLE_UPDATE_SERVICE, "FieldTrialB", 50 AssociateGoogleVariationID(variations::GOOGLE_UPDATE_SERVICE, "FieldTrialB",
51 "Group1", TEST_VALUE_B); 51 "Group1", TEST_VALUE_B);
52 AssociateGoogleVariationID(variations::GOOGLE_UPDATE_SERVICE, "FieldTrialC", 52 AssociateGoogleVariationID(variations::GOOGLE_UPDATE_SERVICE, "FieldTrialC",
53 "Default", TEST_VALUE_C); 53 "Default", TEST_VALUE_C);
54 AssociateGoogleVariationID(variations::GOOGLE_UPDATE_SERVICE, "FieldTrialD", 54 AssociateGoogleVariationID(variations::GOOGLE_UPDATE_SERVICE, "FieldTrialD",
55 "Default", TEST_VALUE_D); // Not actually used. 55 "Default", TEST_VALUE_D); // Not actually used.
56 56
57 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 57 for (size_t i = 0; i < arraysize(test_cases); ++i) {
58 // Parse the input groups. 58 // Parse the input groups.
59 base::FieldTrial::ActiveGroups groups; 59 base::FieldTrial::ActiveGroups groups;
60 std::vector<std::string> group_data; 60 std::vector<std::string> group_data;
61 base::SplitString(test_cases[i].active_group_pairs, '#', &group_data); 61 base::SplitString(test_cases[i].active_group_pairs, '#', &group_data);
62 ASSERT_EQ(0U, group_data.size() % 2); 62 ASSERT_EQ(0U, group_data.size() % 2);
63 for (size_t j = 0; j < group_data.size(); j += 2) { 63 for (size_t j = 0; j < group_data.size(); j += 2) {
64 base::FieldTrial::ActiveGroup group; 64 base::FieldTrial::ActiveGroup group;
65 group.trial_name = group_data[j]; 65 group.trial_name = group_data[j];
66 group.group_name = group_data[j + 1]; 66 group.group_name = group_data[j + 1];
67 groups.push_back(group); 67 groups.push_back(group);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 "A=B|Tue, 21 Jan 2014 15:30:21 GMT"}, 119 "A=B|Tue, 21 Jan 2014 15:30:21 GMT"},
120 {"A=B|Tue, 21 Jan 2014 15:30:21 GMT;C=D|Tue, 21 Jan 2014 15:30:21 GMT", 120 {"A=B|Tue, 21 Jan 2014 15:30:21 GMT;C=D|Tue, 21 Jan 2014 15:30:21 GMT",
121 "P=Q|Tue, 21 Jan 2014 15:30:21 GMT;X=Y|Tue, 21 Jan 2014 15:30:21 GMT", 121 "P=Q|Tue, 21 Jan 2014 15:30:21 GMT;X=Y|Tue, 21 Jan 2014 15:30:21 GMT",
122 "P=Q|Tue, 21 Jan 2014 15:30:21 GMT;X=Y|Tue, 21 Jan 2014 15:30:21 GMT;" 122 "P=Q|Tue, 21 Jan 2014 15:30:21 GMT;X=Y|Tue, 21 Jan 2014 15:30:21 GMT;"
123 "A=B|Tue, 21 Jan 2014 15:30:21 GMT;C=D|Tue, 21 Jan 2014 15:30:21 GMT"}, 123 "A=B|Tue, 21 Jan 2014 15:30:21 GMT;C=D|Tue, 21 Jan 2014 15:30:21 GMT"},
124 {"", 124 {"",
125 "", 125 "",
126 ""}, 126 ""},
127 }; 127 };
128 128
129 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 129 for (size_t i = 0; i < arraysize(test_cases); ++i) {
130 std::string result = base::UTF16ToUTF8(CombineExperimentLabels( 130 std::string result = base::UTF16ToUTF8(CombineExperimentLabels(
131 base::ASCIIToUTF16(test_cases[i].variations_labels), 131 base::ASCIIToUTF16(test_cases[i].variations_labels),
132 base::ASCIIToUTF16(test_cases[i].other_labels))); 132 base::ASCIIToUTF16(test_cases[i].other_labels)));
133 EXPECT_EQ(test_cases[i].expected_label, result); 133 EXPECT_EQ(test_cases[i].expected_label, result);
134 } 134 }
135 } 135 }
136 136
137 TEST(ExperimentLabelsTest, ExtractNonVariationLabels) { 137 TEST(ExperimentLabelsTest, ExtractNonVariationLabels) {
138 struct { 138 struct {
139 const char* input_label; 139 const char* input_label;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 "CrVar1=3310002|Tue, 21 Jan 2014 15:30:21 GMT", 175 "CrVar1=3310002|Tue, 21 Jan 2014 15:30:21 GMT",
176 "gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT"}, 176 "gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT"},
177 // Trailing semicolon 177 // Trailing semicolon
178 {"gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT;" 178 {"gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT;"
179 "CrVar1=3310002|Tue, 21 Jan 2014 15:30:21 GMT;", // Note the semi here. 179 "CrVar1=3310002|Tue, 21 Jan 2014 15:30:21 GMT;", // Note the semi here.
180 "gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT"}, 180 "gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT"},
181 // Semis 181 // Semis
182 {";;;;", ""}, 182 {";;;;", ""},
183 }; 183 };
184 184
185 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 185 for (size_t i = 0; i < arraysize(test_cases); ++i) {
186 std::string non_variation_labels = base::UTF16ToUTF8( 186 std::string non_variation_labels = base::UTF16ToUTF8(
187 ExtractNonVariationLabels( 187 ExtractNonVariationLabels(
188 base::ASCIIToUTF16(test_cases[i].input_label))); 188 base::ASCIIToUTF16(test_cases[i].input_label)));
189 EXPECT_EQ(test_cases[i].expected_output, non_variation_labels); 189 EXPECT_EQ(test_cases[i].expected_output, non_variation_labels);
190 } 190 }
191 } 191 }
192 192
193 } // namespace chrome_variations 193 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « chrome/common/net/x509_certificate_model_openssl.cc ('k') | chrome/renderer/autofill/form_autofill_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698