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

Side by Side Diff: base/version_unittest.cc

Issue 2163033002: base::Version constructor from std::vector<uint32_t> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes based on nit comments Created 4 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 unified diff | Download patch
« no previous file with comments | « base/version.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <utility>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace { 14 namespace {
14 15
15 TEST(VersionTest, DefaultConstructor) { 16 TEST(VersionTest, DefaultConstructor) {
16 Version v; 17 Version v;
17 EXPECT_FALSE(v.IsValid()); 18 EXPECT_FALSE(v.IsValid());
18 } 19 }
19 20
20 TEST(VersionTest, ValueSemantics) { 21 TEST(VersionTest, ValueSemantics) {
21 Version v1("1.2.3.4"); 22 Version v1("1.2.3.4");
22 EXPECT_TRUE(v1.IsValid()); 23 EXPECT_TRUE(v1.IsValid());
23 Version v3; 24 Version v3;
24 EXPECT_FALSE(v3.IsValid()); 25 EXPECT_FALSE(v3.IsValid());
25 { 26 {
26 Version v2(v1); 27 Version v2(v1);
27 v3 = v2; 28 v3 = v2;
28 EXPECT_TRUE(v2.IsValid()); 29 EXPECT_TRUE(v2.IsValid());
29 EXPECT_EQ(v1, v2); 30 EXPECT_EQ(v1, v2);
30 } 31 }
31 EXPECT_EQ(v3, v1); 32 EXPECT_EQ(v3, v1);
32 } 33 }
33 34
35 TEST(VersionTest, MoveSemantics) {
36 const std::vector<uint32_t> components = {1, 2, 3, 4};
37 Version v1(std::move(components));
38 EXPECT_TRUE(v1.IsValid());
39 Version v2("1.2.3.4");
40 EXPECT_EQ(v1, v2);
41 }
42
34 TEST(VersionTest, GetVersionFromString) { 43 TEST(VersionTest, GetVersionFromString) {
35 static const struct version_string { 44 static const struct version_string {
36 const char* input; 45 const char* input;
37 size_t parts; 46 size_t parts;
38 uint32_t firstpart; 47 uint32_t firstpart;
39 bool success; 48 bool success;
40 } cases[] = { 49 } cases[] = {
41 {"", 0, 0, false}, 50 {"", 0, 0, false},
42 {" ", 0, 0, false}, 51 {" ", 0, 0, false},
43 {"\t", 0, 0, false}, 52 {"\t", 0, 0, false},
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 {"*", false}, 184 {"*", false},
176 {"*.2", false}, 185 {"*.2", false},
177 }; 186 };
178 for (size_t i = 0; i < arraysize(cases); ++i) { 187 for (size_t i = 0; i < arraysize(cases); ++i) {
179 EXPECT_EQ(Version::IsValidWildcardString(cases[i].version), 188 EXPECT_EQ(Version::IsValidWildcardString(cases[i].version),
180 cases[i].expected) << cases[i].version << "?" << cases[i].expected; 189 cases[i].expected) << cases[i].version << "?" << cases[i].expected;
181 } 190 }
182 } 191 }
183 192
184 } // namespace 193 } // namespace
OLDNEW
« 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