| OLD | NEW |
| 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 Version v1(std::vector<uint32_t>{1, 2, 3, 4}); |
| 37 EXPECT_TRUE(v1.IsValid()); |
| 38 Version v2("1.2.3.4"); |
| 39 EXPECT_EQ(v1, v2); |
| 40 } |
| 41 |
| 34 TEST(VersionTest, GetVersionFromString) { | 42 TEST(VersionTest, GetVersionFromString) { |
| 35 static const struct version_string { | 43 static const struct version_string { |
| 36 const char* input; | 44 const char* input; |
| 37 size_t parts; | 45 size_t parts; |
| 38 uint32_t firstpart; | 46 uint32_t firstpart; |
| 39 bool success; | 47 bool success; |
| 40 } cases[] = { | 48 } cases[] = { |
| 41 {"", 0, 0, false}, | 49 {"", 0, 0, false}, |
| 42 {" ", 0, 0, false}, | 50 {" ", 0, 0, false}, |
| 43 {"\t", 0, 0, false}, | 51 {"\t", 0, 0, false}, |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 {"*", false}, | 183 {"*", false}, |
| 176 {"*.2", false}, | 184 {"*.2", false}, |
| 177 }; | 185 }; |
| 178 for (size_t i = 0; i < arraysize(cases); ++i) { | 186 for (size_t i = 0; i < arraysize(cases); ++i) { |
| 179 EXPECT_EQ(Version::IsValidWildcardString(cases[i].version), | 187 EXPECT_EQ(Version::IsValidWildcardString(cases[i].version), |
| 180 cases[i].expected) << cases[i].version << "?" << cases[i].expected; | 188 cases[i].expected) << cases[i].version << "?" << cases[i].expected; |
| 181 } | 189 } |
| 182 } | 190 } |
| 183 | 191 |
| 184 } // namespace | 192 } // namespace |
| OLD | NEW |