Commit 7bddd6ce authored by Alexei Svitkine's avatar Alexei Svitkine Committed by Commit Bot

Add some additional test coverage for Version code.

Was double-checking the logic here and realized we didn't
have any unit test coverage for CompareToWildcardString when
wildcards are not passed to it.

BUG=none

Change-Id: I5c30032138b2fc28e3fdaa590756e95dae829234
Reviewed-on: https://chromium-review.googlesource.com/804755
Commit-Queue: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521364}
parent 4f1a7671
...@@ -103,12 +103,19 @@ TEST(VersionTest, Compare) { ...@@ -103,12 +103,19 @@ TEST(VersionTest, Compare) {
{"1.0.3", "1.0.20", -1}, {"1.0.3", "1.0.20", -1},
{"11.0.10", "15.007.20011", -1}, {"11.0.10", "15.007.20011", -1},
{"11.0.10", "15.5.28.130162", -1}, {"11.0.10", "15.5.28.130162", -1},
{"15.5.28.130162", "15.5.28.130162", 0},
}; };
for (size_t i = 0; i < arraysize(cases); ++i) { for (size_t i = 0; i < arraysize(cases); ++i) {
base::Version lhs(cases[i].lhs); base::Version lhs(cases[i].lhs);
base::Version rhs(cases[i].rhs); base::Version rhs(cases[i].rhs);
EXPECT_EQ(lhs.CompareTo(rhs), cases[i].expected) << EXPECT_EQ(lhs.CompareTo(rhs), cases[i].expected) <<
cases[i].lhs << " ? " << cases[i].rhs; cases[i].lhs << " ? " << cases[i].rhs;
// CompareToWildcardString() should have same behavior as CompareTo() when
// no wildcards are present.
EXPECT_EQ(lhs.CompareToWildcardString(cases[i].rhs), cases[i].expected)
<< cases[i].lhs << " ? " << cases[i].rhs;
EXPECT_EQ(rhs.CompareToWildcardString(cases[i].lhs), -cases[i].expected)
<< cases[i].lhs << " ? " << cases[i].rhs;
// Test comparison operators // Test comparison operators
switch (cases[i].expected) { switch (cases[i].expected) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment