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

Unified Diff: base/version_unittest.cc

Issue 10576003: VariationsService now supports wildcard in min/max version (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: addressed brettw's comment Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/version.cc ('k') | chrome/browser/metrics/variations_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/version_unittest.cc
===================================================================
--- base/version_unittest.cc (revision 145458)
+++ base/version_unittest.cc (working copy)
@@ -89,3 +89,53 @@
EXPECT_EQ(lhs->IsOlderThan(cases[i].rhs), (cases[i].expected == -1));
}
}
+
+TEST_F(VersionTest, CompareToWildcardString) {
+ static const struct version_compare {
+ const char* lhs;
+ const char* rhs;
+ int expected;
+ } cases[] = {
+ {"1.0", "1.*", 0},
+ {"1.0", "0.*", 1},
+ {"1.0", "2.*", -1},
+ {"1.2.3", "1.2.3.*", 0},
+ {"10.0", "1.0.*", 1},
+ {"1.0", "3.0.*", -1},
+ {"1.4", "1.3.0.*", 1},
+ {"1.3.9", "1.3.*", 0},
+ {"1.4.1", "1.3.*", 1},
+ {"1.3", "1.4.5.*", -1},
+ {"1.5", "1.4.5.*", 1},
+ {"1.3.9", "1.3.*", 0},
+ {"1.2.0.0.0.0", "1.2.*", 0},
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ const Version version(cases[i].lhs);
+ const int result = version.CompareToWildcardString(cases[i].rhs);
+ EXPECT_EQ(result, cases[i].expected) << cases[i].lhs << "?" << cases[i].rhs;
+ }
+}
+
+TEST_F(VersionTest, IsValidWildcardString) {
+ static const struct version_compare {
+ const char* version;
+ bool expected;
+ } cases[] = {
+ {"1.0", true},
+ {"", false},
+ {"1.2.3.4.5.6", true},
+ {"1.2.3.*", true},
+ {"1.2.3.5*", false},
+ {"1.2.3.56*", false},
+ {"1.*.3", false},
+ {"20.*", true},
+ {"+2.*", false},
+ {"*", false},
+ {"*.2", false},
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ EXPECT_EQ(Version::IsValidWildcardString(cases[i].version),
+ cases[i].expected) << cases[i].version << "?" << cases[i].expected;
+ }
+}
« no previous file with comments | « base/version.cc ('k') | chrome/browser/metrics/variations_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698