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

Side by Side Diff: webrtc/base/versionparsing_unittest.cc

Issue 2373003002: Delete unused file versionparsing.h. (Closed)
Patch Set: Rebased. Created 4 years, 2 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 | « webrtc/base/versionparsing.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
(Empty)
1 /*
2 * Copyright 2010 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/base/versionparsing.h"
12
13 #include "webrtc/base/gunit.h"
14
15 namespace rtc {
16
17 static const int kExampleSegments = 4;
18
19 typedef int ExampleVersion[kExampleSegments];
20
21 TEST(VersionParsing, TestGoodParse) {
22 ExampleVersion ver;
23 std::string str1("1.1.2.0");
24 static const ExampleVersion expect1 = {1, 1, 2, 0};
25 EXPECT_TRUE(ParseVersionString(str1, kExampleSegments, ver));
26 EXPECT_EQ(0, CompareVersions(ver, expect1, kExampleSegments));
27 std::string str2("2.0.0.1");
28 static const ExampleVersion expect2 = {2, 0, 0, 1};
29 EXPECT_TRUE(ParseVersionString(str2, kExampleSegments, ver));
30 EXPECT_EQ(0, CompareVersions(ver, expect2, kExampleSegments));
31 }
32
33 TEST(VersionParsing, TestBadParse) {
34 ExampleVersion ver;
35 std::string str1("1.1.2");
36 EXPECT_FALSE(ParseVersionString(str1, kExampleSegments, ver));
37 std::string str2("");
38 EXPECT_FALSE(ParseVersionString(str2, kExampleSegments, ver));
39 std::string str3("garbarge");
40 EXPECT_FALSE(ParseVersionString(str3, kExampleSegments, ver));
41 }
42
43 TEST(VersionParsing, TestCompare) {
44 static const ExampleVersion ver1 = {1, 0, 21, 0};
45 static const ExampleVersion ver2 = {1, 1, 2, 0};
46 static const ExampleVersion ver3 = {1, 1, 3, 0};
47 static const ExampleVersion ver4 = {1, 1, 3, 9861};
48
49 // Test that every combination of comparisons has the expected outcome.
50 EXPECT_EQ(0, CompareVersions(ver1, ver1, kExampleSegments));
51 EXPECT_EQ(0, CompareVersions(ver2, ver2, kExampleSegments));
52 EXPECT_EQ(0, CompareVersions(ver3, ver3, kExampleSegments));
53 EXPECT_EQ(0, CompareVersions(ver4, ver4, kExampleSegments));
54
55 EXPECT_GT(0, CompareVersions(ver1, ver2, kExampleSegments));
56 EXPECT_LT(0, CompareVersions(ver2, ver1, kExampleSegments));
57
58 EXPECT_GT(0, CompareVersions(ver1, ver3, kExampleSegments));
59 EXPECT_LT(0, CompareVersions(ver3, ver1, kExampleSegments));
60
61 EXPECT_GT(0, CompareVersions(ver1, ver4, kExampleSegments));
62 EXPECT_LT(0, CompareVersions(ver4, ver1, kExampleSegments));
63
64 EXPECT_GT(0, CompareVersions(ver2, ver3, kExampleSegments));
65 EXPECT_LT(0, CompareVersions(ver3, ver2, kExampleSegments));
66
67 EXPECT_GT(0, CompareVersions(ver2, ver4, kExampleSegments));
68 EXPECT_LT(0, CompareVersions(ver4, ver2, kExampleSegments));
69
70 EXPECT_GT(0, CompareVersions(ver3, ver4, kExampleSegments));
71 EXPECT_LT(0, CompareVersions(ver4, ver3, kExampleSegments));
72 }
73
74 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/versionparsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698