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

Unified Diff: base/version_unittest.cc

Issue 1364002: Fixed bug where an empty version string is considered valid. (Closed)
Patch Set: addressed comments Created 10 years, 9 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/version_unittest.cc
diff --git a/base/version_unittest.cc b/base/version_unittest.cc
index d2cf98bcdd0861ff81fc8dbaec90fbcdbcdd9f54..2e3c2ca89a5913d86877735c705f6b7df091ba0e 100644
--- a/base/version_unittest.cc
+++ b/base/version_unittest.cc
@@ -6,14 +6,27 @@
#include "base/version.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace {
+class VersionTest : public testing::Test {
+};
-TEST(Version, GetVersionFromString) {
+TEST_F(VersionTest, DefaultConstructor) {
+ Version v;
+ EXPECT_FALSE(v.is_valid_);
+}
+
+TEST_F(VersionTest, GetVersionFromString) {
static const struct version_string {
const char* input;
size_t parts;
bool success;
} cases[] = {
+ {"", 0, false},
+ {" ", 0, false},
+ {"\t", 0, false},
+ {"\n", 0, false},
+ {" ", 0, false},
+ {".", 0, false},
+ {" . ", 0, false},
{"0", 1, true},
{"0.0", 2, true},
{"65537.0", 0, false},
@@ -29,12 +42,14 @@ TEST(Version, GetVersionFromString) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
scoped_ptr<Version> vers(Version::GetVersionFromString(cases[i].input));
EXPECT_EQ(cases[i].success, vers.get() != NULL);
- if (cases[i].success)
+ if (cases[i].success) {
+ EXPECT_TRUE(vers->is_valid_);
EXPECT_EQ(cases[i].parts, vers->components().size());
+ }
}
}
-TEST(Version, Compare) {
+TEST_F(VersionTest, Compare) {
static const struct version_compare {
const char* lhs;
const char* rhs;
@@ -58,5 +73,3 @@ TEST(Version, Compare) {
cases[i].lhs << " ? " << cases[i].rhs;
}
}
-
-}
« no previous file with comments | « base/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698