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

Side by Side Diff: base/version_unittest.cc

Issue 10683005: Remove two deprecated methods from base::Version (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 8 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 | Annotate | Revision Log
« no previous file with comments | « base/version.cc ('k') | chrome/app/client_util.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/version.h" 6 #include "base/version.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 class VersionTest : public testing::Test { 9 class VersionTest : public testing::Test {
10 }; 10 };
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 {"65537.0", 0, false}, 46 {"65537.0", 0, false},
47 {"-1.0", 0, false}, 47 {"-1.0", 0, false},
48 {"1.-1.0", 0, false}, 48 {"1.-1.0", 0, false},
49 {"+1.0", 0, false}, 49 {"+1.0", 0, false},
50 {"1.+1.0", 0, false}, 50 {"1.+1.0", 0, false},
51 {"1.0a", 0, false}, 51 {"1.0a", 0, false},
52 {"1.2.3.4.5.6.7.8.9.0", 10, true}, 52 {"1.2.3.4.5.6.7.8.9.0", 10, true},
53 {"02.1", 0, false}, 53 {"02.1", 0, false},
54 {"f.1", 0, false}, 54 {"f.1", 0, false},
55 }; 55 };
56
56 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 57 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
57 scoped_ptr<Version> vers(Version::GetVersionFromString(cases[i].input)); 58 Version version(cases[i].input);
58 EXPECT_EQ(cases[i].success, vers.get() != NULL); 59 EXPECT_EQ(cases[i].success, version.IsValid());
59 if (cases[i].success) { 60 if (cases[i].success)
60 EXPECT_TRUE(vers->IsValid()); 61 EXPECT_EQ(cases[i].parts, version.components().size());
61 EXPECT_EQ(cases[i].parts, vers->components().size());
62 }
63 } 62 }
64 } 63 }
65 64
66 TEST_F(VersionTest, Compare) { 65 TEST_F(VersionTest, Compare) {
67 static const struct version_compare { 66 static const struct version_compare {
68 const char* lhs; 67 const char* lhs;
69 const char* rhs; 68 const char* rhs;
70 int expected; 69 int expected;
71 } cases[] = { 70 } cases[] = {
72 {"1.0", "1.0", 0}, 71 {"1.0", "1.0", 0},
73 {"1.0", "0.0", 1}, 72 {"1.0", "0.0", 1},
74 {"1.0", "2.0", -1}, 73 {"1.0", "2.0", -1},
75 {"1.0", "1.1", -1}, 74 {"1.0", "1.1", -1},
76 {"1.1", "1.0", 1}, 75 {"1.1", "1.0", 1},
77 {"1.0", "1.0.1", -1}, 76 {"1.0", "1.0.1", -1},
78 {"1.1", "1.0.1", 1}, 77 {"1.1", "1.0.1", 1},
79 {"1.1", "1.0.1", 1}, 78 {"1.1", "1.0.1", 1},
80 {"1.0.0", "1.0", 0}, 79 {"1.0.0", "1.0", 0},
81 {"1.0.3", "1.0.20", -1}, 80 {"1.0.3", "1.0.20", -1},
82 }; 81 };
83 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 82 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
84 scoped_ptr<Version> lhs(Version::GetVersionFromString(cases[i].lhs)); 83 Version lhs(cases[i].lhs);
85 scoped_ptr<Version> rhs(Version::GetVersionFromString(cases[i].rhs)); 84 Version rhs(cases[i].rhs);
86 EXPECT_EQ(lhs->CompareTo(*rhs), cases[i].expected) << 85 EXPECT_EQ(lhs.CompareTo(rhs), cases[i].expected) <<
87 cases[i].lhs << " ? " << cases[i].rhs; 86 cases[i].lhs << " ? " << cases[i].rhs;
88 87
89 EXPECT_EQ(lhs->IsOlderThan(cases[i].rhs), (cases[i].expected == -1)); 88 EXPECT_EQ(lhs.IsOlderThan(cases[i].rhs), (cases[i].expected == -1));
90 } 89 }
91 } 90 }
OLDNEW
« no previous file with comments | « base/version.cc ('k') | chrome/app/client_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698