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

Side by Side Diff: net/quic/quic_socket_address_coder_test.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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 | « net/quic/quic_socket_address_coder.cc ('k') | net/quic/quic_spdy_session.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "net/quic/quic_socket_address_coder.h" 5 #include "net/quic/quic_socket_address_coder.h"
6 6
7 #include "net/base/sys_addrinfo.h" 7 #include "net/base/sys_addrinfo.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 using std::string; 10 using std::string;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ASSERT_FALSE(serialized.empty()); 92 ASSERT_FALSE(serialized.empty());
93 serialized.erase(serialized.length() - 1); 93 serialized.erase(serialized.length() - 1);
94 EXPECT_FALSE(coder.Decode(serialized.data(), serialized.length())); 94 EXPECT_FALSE(coder.Decode(serialized.data(), serialized.length()));
95 } 95 }
96 EXPECT_TRUE(serialized.empty()); 96 EXPECT_TRUE(serialized.empty());
97 } 97 }
98 98
99 TEST(QuicSocketAddressCoderTest, EncodeAndDecode) { 99 TEST(QuicSocketAddressCoderTest, EncodeAndDecode) {
100 struct { 100 struct {
101 const char* ip_literal; 101 const char* ip_literal;
102 uint16 port; 102 uint16_t port;
103 } test_case[] = { 103 } test_case[] = {
104 {"93.184.216.119", 0x1234}, 104 {"93.184.216.119", 0x1234},
105 {"199.204.44.194", 80}, 105 {"199.204.44.194", 80},
106 {"149.20.4.69", 443}, 106 {"149.20.4.69", 443},
107 {"127.0.0.1", 8080}, 107 {"127.0.0.1", 8080},
108 {"2001:700:300:1800::", 0x5678}, 108 {"2001:700:300:1800::", 0x5678},
109 {"::1", 65534}, 109 {"::1", 65534},
110 }; 110 };
111 111
112 for (size_t i = 0; i < arraysize(test_case); i++) { 112 for (size_t i = 0; i < arraysize(test_case); i++) {
113 IPAddressNumber ip; 113 IPAddressNumber ip;
114 ASSERT_TRUE(ParseIPLiteralToNumber(test_case[i].ip_literal, &ip)); 114 ASSERT_TRUE(ParseIPLiteralToNumber(test_case[i].ip_literal, &ip));
115 QuicSocketAddressCoder encoder(IPEndPoint(ip, test_case[i].port)); 115 QuicSocketAddressCoder encoder(IPEndPoint(ip, test_case[i].port));
116 string serialized = encoder.Encode(); 116 string serialized = encoder.Encode();
117 117
118 QuicSocketAddressCoder decoder; 118 QuicSocketAddressCoder decoder;
119 ASSERT_TRUE(decoder.Decode(serialized.data(), serialized.length())); 119 ASSERT_TRUE(decoder.Decode(serialized.data(), serialized.length()));
120 EXPECT_EQ(encoder.ip(), decoder.ip()); 120 EXPECT_EQ(encoder.ip(), decoder.ip());
121 EXPECT_EQ(encoder.port(), decoder.port()); 121 EXPECT_EQ(encoder.port(), decoder.port());
122 } 122 }
123 } 123 }
124 124
125 } // namespace test 125 } // namespace test
126 } // namespace net 126 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_socket_address_coder.cc ('k') | net/quic/quic_spdy_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698