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

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

Issue 2877023002: Move webrtc/{base => rtc_base} (Closed)
Patch Set: update presubmit.py and DEPS include rules Created 3 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 | « webrtc/base/win32.cc ('k') | webrtc/base/win32filesystem.h » ('j') | 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 <string>
12
13 #include "webrtc/base/gunit.h"
14 #include "webrtc/base/nethelpers.h"
15 #include "webrtc/base/win32.h"
16
17 #if !defined(WEBRTC_WIN)
18 #error Only for Windows
19 #endif
20
21 namespace rtc {
22
23 class Win32Test : public testing::Test {
24 public:
25 Win32Test() {
26 }
27 };
28
29 TEST_F(Win32Test, FileTimeToUInt64Test) {
30 FILETIME ft;
31 ft.dwHighDateTime = 0xBAADF00D;
32 ft.dwLowDateTime = 0xFEED3456;
33
34 uint64_t expected = 0xBAADF00DFEED3456;
35 EXPECT_EQ(expected, ToUInt64(ft));
36 }
37
38 TEST_F(Win32Test, IPv6AddressCompression) {
39 IPAddress ipv6;
40
41 // Zero compression should be done on the leftmost 0s when there are
42 // multiple longest series.
43 ASSERT_TRUE(IPFromString("2a00:8a00:a000:1190:0000:0001:000:252", &ipv6));
44 EXPECT_EQ("2a00:8a00:a000:1190::1:0:252", ipv6.ToString());
45
46 // Ensure the zero compression could handle multiple octects.
47 ASSERT_TRUE(IPFromString("0:0:0:0:0:0:0:1", &ipv6));
48 EXPECT_EQ("::1", ipv6.ToString());
49
50 // Make sure multiple 0 octects compressed.
51 ASSERT_TRUE(IPFromString("fe80:0:0:0:2aa:ff:fe9a:4ca2", &ipv6));
52 EXPECT_EQ("fe80::2aa:ff:fe9a:4ca2", ipv6.ToString());
53
54 // Test zero compression at the end of string.
55 ASSERT_TRUE(IPFromString("2a00:8a00:a000:1190:0000:0001:000:00", &ipv6));
56 EXPECT_EQ("2a00:8a00:a000:1190:0:1::", ipv6.ToString());
57
58 // Test zero compression at the beginning of string.
59 ASSERT_TRUE(IPFromString("0:0:000:1190:0000:0001:000:00", &ipv6));
60 EXPECT_EQ("::1190:0:1:0:0", ipv6.ToString());
61
62 // Test zero compression only done once.
63 ASSERT_TRUE(IPFromString("0:1:000:1190:0000:0001:000:01", &ipv6));
64 EXPECT_EQ("::1:0:1190:0:1:0:1", ipv6.ToString());
65
66 // Make sure noncompressable IPv6 is the same.
67 ASSERT_TRUE(IPFromString("1234:5678:abcd:1234:5678:abcd:1234:5678", &ipv6));
68 EXPECT_EQ("1234:5678:abcd:1234:5678:abcd:1234:5678", ipv6.ToString());
69 }
70
71 // Test that invalid IPv6 addresses are recognized and false is returned.
72 TEST_F(Win32Test, InvalidIPv6AddressParsing) {
73 IPAddress ipv6;
74
75 // More than 1 run of "::"s.
76 EXPECT_FALSE(IPFromString("1::2::3", &ipv6));
77
78 // More than 1 run of "::"s in a longer address.
79 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7592
80 EXPECT_FALSE(IPFromString("1::2::3::4::5::6::7::8", &ipv6));
81
82 // Three ':'s in a row.
83 EXPECT_FALSE(IPFromString("1:::2", &ipv6));
84
85 // Non-hex character.
86 EXPECT_FALSE(IPFromString("test::1", &ipv6));
87
88 // More than 4 hex digits per group.
89 EXPECT_FALSE(IPFromString("abcde::1", &ipv6));
90
91 // More than 8 groups.
92 EXPECT_FALSE(IPFromString("1:2:3:4:5:6:7:8:9", &ipv6));
93
94 // Less than 8 groups.
95 EXPECT_FALSE(IPFromString("1:2:3:4:5:6:7", &ipv6));
96 }
97
98 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/win32.cc ('k') | webrtc/base/win32filesystem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698