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

Side by Side Diff: net/quic/crypto/crypto_framer_test.cc

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « net/quic/crypto/crypto_framer.cc ('k') | net/quic/crypto/crypto_handshake_message.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) 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 <map> 5 #include <map>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "net/quic/crypto/crypto_framer.h" 10 #include "net/quic/crypto/crypto_framer.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // value 2 81 // value 2
82 'g', 'h', 'i', 'j', 82 'g', 'h', 'i', 'j',
83 'k', 83 'k',
84 // value 3 84 // value 3
85 'l', 'm', 'n', 'o', 85 'l', 'm', 'n', 'o',
86 'p', 'q', 'r', 86 'p', 'q', 'r',
87 }; 87 };
88 88
89 CryptoFramer framer; 89 CryptoFramer framer;
90 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); 90 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
91 ASSERT_TRUE(data.get() != NULL); 91 ASSERT_TRUE(data.get() != nullptr);
92 test::CompareCharArraysWithHexError("constructed packet", data->data(), 92 test::CompareCharArraysWithHexError("constructed packet", data->data(),
93 data->length(), AsChars(packet), 93 data->length(), AsChars(packet),
94 arraysize(packet)); 94 arraysize(packet));
95 } 95 }
96 96
97 TEST(CryptoFramerTest, ConstructHandshakeMessageWithTwoKeys) { 97 TEST(CryptoFramerTest, ConstructHandshakeMessageWithTwoKeys) {
98 CryptoHandshakeMessage message; 98 CryptoHandshakeMessage message;
99 message.set_tag(0xFFAA7733); 99 message.set_tag(0xFFAA7733);
100 message.SetStringPiece(0x12345678, "abcdef"); 100 message.SetStringPiece(0x12345678, "abcdef");
101 message.SetStringPiece(0x12345679, "ghijk"); 101 message.SetStringPiece(0x12345679, "ghijk");
(...skipping 16 matching lines...) Expand all
118 // value 1 118 // value 1
119 'a', 'b', 'c', 'd', 119 'a', 'b', 'c', 'd',
120 'e', 'f', 120 'e', 'f',
121 // value 2 121 // value 2
122 'g', 'h', 'i', 'j', 122 'g', 'h', 'i', 'j',
123 'k', 123 'k',
124 }; 124 };
125 125
126 CryptoFramer framer; 126 CryptoFramer framer;
127 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); 127 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
128 ASSERT_TRUE(data.get() != NULL); 128 ASSERT_TRUE(data.get() != nullptr);
129 129
130 test::CompareCharArraysWithHexError("constructed packet", data->data(), 130 test::CompareCharArraysWithHexError("constructed packet", data->data(),
131 data->length(), AsChars(packet), 131 data->length(), AsChars(packet),
132 arraysize(packet)); 132 arraysize(packet));
133 } 133 }
134 134
135 TEST(CryptoFramerTest, ConstructHandshakeMessageZeroLength) { 135 TEST(CryptoFramerTest, ConstructHandshakeMessageZeroLength) {
136 CryptoHandshakeMessage message; 136 CryptoHandshakeMessage message;
137 message.set_tag(0xFFAA7733); 137 message.set_tag(0xFFAA7733);
138 message.SetStringPiece(0x12345678, ""); 138 message.SetStringPiece(0x12345678, "");
139 139
140 unsigned char packet[] = { 140 unsigned char packet[] = {
141 // tag 141 // tag
142 0x33, 0x77, 0xAA, 0xFF, 142 0x33, 0x77, 0xAA, 0xFF,
143 // num entries 143 // num entries
144 0x01, 0x00, 144 0x01, 0x00,
145 // padding 145 // padding
146 0x00, 0x00, 146 0x00, 0x00,
147 // tag 1 147 // tag 1
148 0x78, 0x56, 0x34, 0x12, 148 0x78, 0x56, 0x34, 0x12,
149 // end offset 1 149 // end offset 1
150 0x00, 0x00, 0x00, 0x00, 150 0x00, 0x00, 0x00, 0x00,
151 }; 151 };
152 152
153 CryptoFramer framer; 153 CryptoFramer framer;
154 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); 154 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
155 ASSERT_TRUE(data.get() != NULL); 155 ASSERT_TRUE(data.get() != nullptr);
156 156
157 test::CompareCharArraysWithHexError("constructed packet", data->data(), 157 test::CompareCharArraysWithHexError("constructed packet", data->data(),
158 data->length(), AsChars(packet), 158 data->length(), AsChars(packet),
159 arraysize(packet)); 159 arraysize(packet));
160 } 160 }
161 161
162 TEST(CryptoFramerTest, ConstructHandshakeMessageTooManyEntries) { 162 TEST(CryptoFramerTest, ConstructHandshakeMessageTooManyEntries) {
163 CryptoHandshakeMessage message; 163 CryptoHandshakeMessage message;
164 message.set_tag(0xFFAA7733); 164 message.set_tag(0xFFAA7733);
165 for (uint32 key = 1; key <= kMaxEntries + 1; ++key) { 165 for (uint32 key = 1; key <= kMaxEntries + 1; ++key) {
166 message.SetStringPiece(key, "abcdef"); 166 message.SetStringPiece(key, "abcdef");
167 } 167 }
168 168
169 CryptoFramer framer; 169 CryptoFramer framer;
170 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); 170 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
171 EXPECT_TRUE(data.get() == NULL); 171 EXPECT_TRUE(data.get() == nullptr);
172 } 172 }
173 173
174 TEST(CryptoFramerTest, ConstructHandshakeMessageMinimumSize) { 174 TEST(CryptoFramerTest, ConstructHandshakeMessageMinimumSize) {
175 CryptoHandshakeMessage message; 175 CryptoHandshakeMessage message;
176 message.set_tag(0xFFAA7733); 176 message.set_tag(0xFFAA7733);
177 message.SetStringPiece(0x01020304, "test"); 177 message.SetStringPiece(0x01020304, "test");
178 message.set_minimum_size(64); 178 message.set_minimum_size(64);
179 179
180 unsigned char packet[] = { 180 unsigned char packet[] = {
181 // tag 181 // tag
(...skipping 15 matching lines...) Expand all
197 '-', '-', '-', '-', '-', '-', '-', '-', 197 '-', '-', '-', '-', '-', '-', '-', '-',
198 '-', '-', '-', '-', '-', '-', '-', '-', 198 '-', '-', '-', '-', '-', '-', '-', '-',
199 '-', '-', '-', '-', '-', '-', '-', '-', 199 '-', '-', '-', '-', '-', '-', '-', '-',
200 '-', '-', '-', '-', 200 '-', '-', '-', '-',
201 // value 2 201 // value 2
202 't', 'e', 's', 't', 202 't', 'e', 's', 't',
203 }; 203 };
204 204
205 CryptoFramer framer; 205 CryptoFramer framer;
206 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); 206 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
207 ASSERT_TRUE(data.get() != NULL); 207 ASSERT_TRUE(data.get() != nullptr);
208 208
209 test::CompareCharArraysWithHexError("constructed packet", data->data(), 209 test::CompareCharArraysWithHexError("constructed packet", data->data(),
210 data->length(), AsChars(packet), 210 data->length(), AsChars(packet),
211 arraysize(packet)); 211 arraysize(packet));
212 } 212 }
213 213
214 TEST(CryptoFramerTest, ConstructHandshakeMessageMinimumSizePadLast) { 214 TEST(CryptoFramerTest, ConstructHandshakeMessageMinimumSizePadLast) {
215 CryptoHandshakeMessage message; 215 CryptoHandshakeMessage message;
216 message.set_tag(0xFFAA7733); 216 message.set_tag(0xFFAA7733);
217 message.SetStringPiece(1, ""); 217 message.SetStringPiece(1, "");
(...skipping 17 matching lines...) Expand all
235 // 40 bytes of padding. 235 // 40 bytes of padding.
236 '-', '-', '-', '-', '-', '-', '-', '-', 236 '-', '-', '-', '-', '-', '-', '-', '-',
237 '-', '-', '-', '-', '-', '-', '-', '-', 237 '-', '-', '-', '-', '-', '-', '-', '-',
238 '-', '-', '-', '-', '-', '-', '-', '-', 238 '-', '-', '-', '-', '-', '-', '-', '-',
239 '-', '-', '-', '-', '-', '-', '-', '-', 239 '-', '-', '-', '-', '-', '-', '-', '-',
240 '-', '-', '-', '-', '-', '-', '-', '-', 240 '-', '-', '-', '-', '-', '-', '-', '-',
241 }; 241 };
242 242
243 CryptoFramer framer; 243 CryptoFramer framer;
244 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); 244 scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
245 ASSERT_TRUE(data.get() != NULL); 245 ASSERT_TRUE(data.get() != nullptr);
246 246
247 test::CompareCharArraysWithHexError("constructed packet", data->data(), 247 test::CompareCharArraysWithHexError("constructed packet", data->data(),
248 data->length(), AsChars(packet), 248 data->length(), AsChars(packet),
249 arraysize(packet)); 249 arraysize(packet));
250 } 250 }
251 251
252 TEST(CryptoFramerTest, ProcessInput) { 252 TEST(CryptoFramerTest, ProcessInput) {
253 test::TestCryptoVisitor visitor; 253 test::TestCryptoVisitor visitor;
254 CryptoFramer framer; 254 CryptoFramer framer;
255 framer.set_visitor(&visitor); 255 framer.set_visitor(&visitor);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 }; 476 };
477 477
478 EXPECT_TRUE( 478 EXPECT_TRUE(
479 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input)))); 479 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input))));
480 EXPECT_EQ(0, visitor.error_count_); 480 EXPECT_EQ(0, visitor.error_count_);
481 } 481 }
482 482
483 } // namespace test 483 } // namespace test
484 484
485 } // namespace net 485 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/crypto_framer.cc ('k') | net/quic/crypto/crypto_handshake_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698