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

Side by Side Diff: components/variations/study_filtering_unittest.cc

Issue 2258263002: Consistently use namespaced base::Version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased against master. Created 4 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
« no previous file with comments | « components/variations/processed_study.cc ('k') | ios/chrome/browser/net/crl_set_fetcher.cc » ('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 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 "components/variations/study_filtering.h" 5 #include "components/variations/study_filtering.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 { "1.*", "2.3.4", false }, 273 { "1.*", "2.3.4", false },
274 }; 274 };
275 275
276 Study_Filter filter; 276 Study_Filter filter;
277 277
278 // Min/max version not set should result in true. 278 // Min/max version not set should result in true.
279 EXPECT_TRUE(internal::CheckStudyVersion(filter, base::Version("1.2.3"))); 279 EXPECT_TRUE(internal::CheckStudyVersion(filter, base::Version("1.2.3")));
280 280
281 for (size_t i = 0; i < arraysize(min_test_cases); ++i) { 281 for (size_t i = 0; i < arraysize(min_test_cases); ++i) {
282 filter.set_min_version(min_test_cases[i].min_version); 282 filter.set_min_version(min_test_cases[i].min_version);
283 const bool result = 283 const bool result = internal::CheckStudyVersion(
284 internal::CheckStudyVersion(filter, Version(min_test_cases[i].version)); 284 filter, base::Version(min_test_cases[i].version));
285 EXPECT_EQ(min_test_cases[i].expected_result, result) << 285 EXPECT_EQ(min_test_cases[i].expected_result, result) <<
286 "Min. version case " << i << " failed!"; 286 "Min. version case " << i << " failed!";
287 } 287 }
288 filter.clear_min_version(); 288 filter.clear_min_version();
289 289
290 for (size_t i = 0; i < arraysize(max_test_cases); ++i) { 290 for (size_t i = 0; i < arraysize(max_test_cases); ++i) {
291 filter.set_max_version(max_test_cases[i].max_version); 291 filter.set_max_version(max_test_cases[i].max_version);
292 const bool result = 292 const bool result = internal::CheckStudyVersion(
293 internal::CheckStudyVersion(filter, Version(max_test_cases[i].version)); 293 filter, base::Version(max_test_cases[i].version));
294 EXPECT_EQ(max_test_cases[i].expected_result, result) << 294 EXPECT_EQ(max_test_cases[i].expected_result, result) <<
295 "Max version case " << i << " failed!"; 295 "Max version case " << i << " failed!";
296 } 296 }
297 297
298 // Check intersection semantics. 298 // Check intersection semantics.
299 for (size_t i = 0; i < arraysize(min_test_cases); ++i) { 299 for (size_t i = 0; i < arraysize(min_test_cases); ++i) {
300 for (size_t j = 0; j < arraysize(max_test_cases); ++j) { 300 for (size_t j = 0; j < arraysize(max_test_cases); ++j) {
301 filter.set_min_version(min_test_cases[i].min_version); 301 filter.set_min_version(min_test_cases[i].min_version);
302 filter.set_max_version(max_test_cases[j].max_version); 302 filter.set_max_version(max_test_cases[j].max_version);
303 303
304 if (!min_test_cases[i].expected_result) { 304 if (!min_test_cases[i].expected_result) {
305 const bool result = 305 const bool result = internal::CheckStudyVersion(
306 internal::CheckStudyVersion( 306 filter, base::Version(min_test_cases[i].version));
307 filter, Version(min_test_cases[i].version));
308 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!"; 307 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!";
309 } 308 }
310 309
311 if (!max_test_cases[j].expected_result) { 310 if (!max_test_cases[j].expected_result) {
312 const bool result = 311 const bool result = internal::CheckStudyVersion(
313 internal::CheckStudyVersion( 312 filter, base::Version(max_test_cases[j].version));
314 filter, Version(max_test_cases[j].version));
315 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!"; 313 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!";
316 } 314 }
317 } 315 }
318 } 316 }
319 } 317 }
320 318
321 TEST(VariationsStudyFilteringTest, CheckStudyHardwareClass) { 319 TEST(VariationsStudyFilteringTest, CheckStudyHardwareClass) {
322 struct { 320 struct {
323 const char* hardware_class; 321 const char* hardware_class;
324 const char* exclude_hardware_class; 322 const char* exclude_hardware_class;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 571
574 default_group->set_name("def"); 572 default_group->set_name("def");
575 EXPECT_TRUE(processed_study.Init(&study, false)); 573 EXPECT_TRUE(processed_study.Init(&study, false));
576 Study_Experiment* repeated_group = study.add_experiment(); 574 Study_Experiment* repeated_group = study.add_experiment();
577 repeated_group->set_name("abc"); 575 repeated_group->set_name("abc");
578 repeated_group->set_probability_weight(1); 576 repeated_group->set_probability_weight(1);
579 EXPECT_FALSE(processed_study.Init(&study, false)); 577 EXPECT_FALSE(processed_study.Init(&study, false));
580 } 578 }
581 579
582 } // namespace variations 580 } // namespace variations
OLDNEW
« no previous file with comments | « components/variations/processed_study.cc ('k') | ios/chrome/browser/net/crl_set_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698