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

Side by Side Diff: base/version_unittest.cc

Issue 1575523002: Comparison and streaming operators for base::Version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/version.h" 5 #include "base/version.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace { 13 namespace {
14 14
15 TEST(VersionTest, DefaultConstructor) { 15 TEST(VersionTest, DefaultConstructor) {
16 Version v; 16 Version v;
17 EXPECT_FALSE(v.IsValid()); 17 EXPECT_FALSE(v.IsValid());
18 } 18 }
19 19
20 TEST(VersionTest, ValueSemantics) { 20 TEST(VersionTest, ValueSemantics) {
21 Version v1("1.2.3.4"); 21 Version v1("1.2.3.4");
22 EXPECT_TRUE(v1.IsValid()); 22 EXPECT_TRUE(v1.IsValid());
23 Version v3; 23 Version v3;
24 EXPECT_FALSE(v3.IsValid()); 24 EXPECT_FALSE(v3.IsValid());
25 { 25 {
26 Version v2(v1); 26 Version v2(v1);
27 v3 = v2; 27 v3 = v2;
28 EXPECT_TRUE(v2.IsValid()); 28 EXPECT_TRUE(v2.IsValid());
29 EXPECT_TRUE(v1.Equals(v2)); 29 EXPECT_EQ(v1, v2);
30 } 30 }
31 EXPECT_TRUE(v3.Equals(v1)); 31 EXPECT_EQ(v3, v1);
32 } 32 }
33 33
34 TEST(VersionTest, GetVersionFromString) { 34 TEST(VersionTest, GetVersionFromString) {
35 static const struct version_string { 35 static const struct version_string {
36 const char* input; 36 const char* input;
37 size_t parts; 37 size_t parts;
38 uint32_t firstpart; 38 uint32_t firstpart;
39 bool success; 39 bool success;
40 } cases[] = { 40 } cases[] = {
41 {"", 0, 0, false}, 41 {"", 0, 0, false},
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 {"*", false}, 149 {"*", false},
150 {"*.2", false}, 150 {"*.2", false},
151 }; 151 };
152 for (size_t i = 0; i < arraysize(cases); ++i) { 152 for (size_t i = 0; i < arraysize(cases); ++i) {
153 EXPECT_EQ(Version::IsValidWildcardString(cases[i].version), 153 EXPECT_EQ(Version::IsValidWildcardString(cases[i].version),
154 cases[i].expected) << cases[i].version << "?" << cases[i].expected; 154 cases[i].expected) << cases[i].version << "?" << cases[i].expected;
155 } 155 }
156 } 156 }
157 157
158 } // namespace 158 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698