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

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: Created 8 years, 6 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
Index: base/version_unittest.cc
===================================================================
--- base/version_unittest.cc (revision 142705)
+++ base/version_unittest.cc (working copy)
@@ -89,3 +89,42 @@
EXPECT_EQ(lhs->IsOlderThan(cases[i].rhs), (cases[i].expected == -1));
}
}
+
+TEST_F(VersionTest, CompareToWildcard) {
+ 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},
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ scoped_ptr<Version> lhs(Version::GetVersionFromString(cases[i].lhs));
Alexei Svitkine (slow) 2012/06/18 22:03:44 Don't use GetVersionFromString() - it has a commen
Mathieu 2012/06/19 14:30:20 Done.
+ EXPECT_EQ(lhs->CompareToWildcard(cases[i].rhs), cases[i].expected) <<
+ cases[i].lhs << " <-> " << cases[i].rhs;
+ }
+}
+
+TEST_F(VersionTest, IsValidWildcard) {
+ static const struct version_compare {
+ const char* version;
+ bool expected;
+ } cases[] = {
+ {"1.0", true},
+ {"1.2.3.4.5.6", true},
+ {"1.2.3.*", true},
+ {"20.*", true},
+ {"+2.*", false},
+ {"*", false},
+ {"*.2", false},
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ EXPECT_EQ(Version::IsValidWildcard(cases[i].version), cases[i].expected) <<
+ cases[i].version << " failed -> " << cases[i].expected;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698