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

Side by Side Diff: net/spdy/hpack/hpack_input_stream_test.cc

Issue 2801603003: Add SpdyString alias for std::string in net/spdy. (Closed)
Patch Set: Created 3 years, 8 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/spdy/hpack/hpack_input_stream.cc ('k') | net/spdy/hpack/hpack_output_stream.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/spdy/hpack/hpack_input_stream.h" 5 #include "net/spdy/hpack/hpack_input_stream.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 #include <string>
9 #include <vector> 8 #include <vector>
10 9
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "net/spdy/hpack/hpack_constants.h" 11 #include "net/spdy/hpack/hpack_constants.h"
13 #include "net/spdy/spdy_test_utils.h" 12 #include "net/spdy/spdy_test_utils.h"
14 #include "net/test/gtest_util.h" 13 #include "net/test/gtest_util.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 15
17 namespace net { 16 namespace net {
18 17
19 namespace test { 18 namespace test {
20 19
21 using std::string;
22 using test::a2b_hex; 20 using test::a2b_hex;
23 21
24 // Hex representation of encoded length and Huffman string. 22 // Hex representation of encoded length and Huffman string.
25 const char kEncodedHuffmanFixture[] = 23 const char kEncodedHuffmanFixture[] =
26 "2d" // Length prefix. 24 "2d" // Length prefix.
27 "94e7821dd7f2e6c7b335dfdfcd5b3960" 25 "94e7821dd7f2e6c7b335dfdfcd5b3960"
28 "d5af27087f3672c1ab270fb5291f9587" 26 "d5af27087f3672c1ab270fb5291f9587"
29 "316065c003ed4ee5b1063d5007"; 27 "316065c003ed4ee5b1063d5007";
30 28
31 const char kDecodedHuffmanFixture[] = 29 const char kDecodedHuffmanFixture[] =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 void ExpectDecodeUint32Invalid(uint8_t N, SpdyStringPiece str) { 64 void ExpectDecodeUint32Invalid(uint8_t N, SpdyStringPiece str) {
67 EXPECT_GT(N, 0); 65 EXPECT_GT(N, 0);
68 EXPECT_LE(N, 8); 66 EXPECT_LE(N, 8);
69 HpackInputStream input_stream(str); 67 HpackInputStream input_stream(str);
70 HpackInputStreamPeer input_stream_peer(&input_stream); 68 HpackInputStreamPeer input_stream_peer(&input_stream);
71 input_stream_peer.SetBitOffsetForTest(8 - N); 69 input_stream_peer.SetBitOffsetForTest(8 - N);
72 uint32_t I; 70 uint32_t I;
73 EXPECT_FALSE(input_stream.DecodeNextUint32(&I)); 71 EXPECT_FALSE(input_stream.DecodeNextUint32(&I));
74 } 72 }
75 73
76 uint32_t bits32(const string& bitstring) { 74 uint32_t bits32(const SpdyString& bitstring) {
77 return std::bitset<32>(bitstring).to_ulong(); 75 return std::bitset<32>(bitstring).to_ulong();
78 } 76 }
79 77
80 // The {Number}ByteIntegersEightBitPrefix tests below test that 78 // The {Number}ByteIntegersEightBitPrefix tests below test that
81 // certain integers are decoded correctly with an 8-bit prefix in 79 // certain integers are decoded correctly with an 8-bit prefix in
82 // exactly {Number} bytes. 80 // exactly {Number} bytes.
83 81
84 TEST(HpackInputStreamTest, OneByteIntegersEightBitPrefix) { 82 TEST(HpackInputStreamTest, OneByteIntegersEightBitPrefix) {
85 // Minimum. 83 // Minimum.
86 EXPECT_EQ(0x00u, DecodeValidUint32(8, string("\x00", 1))); 84 EXPECT_EQ(0x00u, DecodeValidUint32(8, SpdyString("\x00", 1)));
87 EXPECT_EQ(0x7fu, DecodeValidUint32(8, "\x7f")); 85 EXPECT_EQ(0x7fu, DecodeValidUint32(8, "\x7f"));
88 // Maximum. 86 // Maximum.
89 EXPECT_EQ(0xfeu, DecodeValidUint32(8, "\xfe")); 87 EXPECT_EQ(0xfeu, DecodeValidUint32(8, "\xfe"));
90 // Invalid. 88 // Invalid.
91 ExpectDecodeUint32Invalid(8, "\xff"); 89 ExpectDecodeUint32Invalid(8, "\xff");
92 } 90 }
93 91
94 TEST(HpackInputStreamTest, TwoByteIntegersEightBitPrefix) { 92 TEST(HpackInputStreamTest, TwoByteIntegersEightBitPrefix) {
95 // Minimum. 93 // Minimum.
96 EXPECT_EQ(0xffu, DecodeValidUint32(8, string("\xff\x00", 2))); 94 EXPECT_EQ(0xffu, DecodeValidUint32(8, SpdyString("\xff\x00", 2)));
97 EXPECT_EQ(0x0100u, DecodeValidUint32(8, "\xff\x01")); 95 EXPECT_EQ(0x0100u, DecodeValidUint32(8, "\xff\x01"));
98 // Maximum. 96 // Maximum.
99 EXPECT_EQ(0x017eu, DecodeValidUint32(8, "\xff\x7f")); 97 EXPECT_EQ(0x017eu, DecodeValidUint32(8, "\xff\x7f"));
100 // Invalid. 98 // Invalid.
101 ExpectDecodeUint32Invalid(8, "\xff\x80"); 99 ExpectDecodeUint32Invalid(8, "\xff\x80");
102 ExpectDecodeUint32Invalid(8, "\xff\xff"); 100 ExpectDecodeUint32Invalid(8, "\xff\xff");
103 } 101 }
104 102
105 TEST(HpackInputStreamTest, ThreeByteIntegersEightBitPrefix) { 103 TEST(HpackInputStreamTest, ThreeByteIntegersEightBitPrefix) {
106 // Minimum. 104 // Minimum.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 ExpectDecodeUint32Invalid(8, "\xff\x80\x80\x80\x80\x80\x01"); 157 ExpectDecodeUint32Invalid(8, "\xff\x80\x80\x80\x80\x80\x01");
160 ExpectDecodeUint32Invalid(8, "\xff\xff\xff\xff\xff\xff\xff"); 158 ExpectDecodeUint32Invalid(8, "\xff\xff\xff\xff\xff\xff\xff");
161 } 159 }
162 160
163 // The {Number}ByteIntegersOneToSevenBitPrefix tests below test that 161 // The {Number}ByteIntegersOneToSevenBitPrefix tests below test that
164 // certain integers are encoded correctly with an N-bit prefix in 162 // certain integers are encoded correctly with an N-bit prefix in
165 // exactly {Number} bytes for N in {1, 2, ..., 7}. 163 // exactly {Number} bytes for N in {1, 2, ..., 7}.
166 164
167 TEST(HpackInputStreamTest, OneByteIntegersOneToSevenBitPrefixes) { 165 TEST(HpackInputStreamTest, OneByteIntegersOneToSevenBitPrefixes) {
168 // Minimums. 166 // Minimums.
169 EXPECT_EQ(0x00u, DecodeValidUint32(7, string("\x00", 1))); 167 EXPECT_EQ(0x00u, DecodeValidUint32(7, SpdyString("\x00", 1)));
170 EXPECT_EQ(0x00u, DecodeValidUint32(7, "\x80")); 168 EXPECT_EQ(0x00u, DecodeValidUint32(7, "\x80"));
171 EXPECT_EQ(0x00u, DecodeValidUint32(6, string("\x00", 1))); 169 EXPECT_EQ(0x00u, DecodeValidUint32(6, SpdyString("\x00", 1)));
172 EXPECT_EQ(0x00u, DecodeValidUint32(6, "\xc0")); 170 EXPECT_EQ(0x00u, DecodeValidUint32(6, "\xc0"));
173 EXPECT_EQ(0x00u, DecodeValidUint32(5, string("\x00", 1))); 171 EXPECT_EQ(0x00u, DecodeValidUint32(5, SpdyString("\x00", 1)));
174 EXPECT_EQ(0x00u, DecodeValidUint32(5, "\xe0")); 172 EXPECT_EQ(0x00u, DecodeValidUint32(5, "\xe0"));
175 EXPECT_EQ(0x00u, DecodeValidUint32(4, string("\x00", 1))); 173 EXPECT_EQ(0x00u, DecodeValidUint32(4, SpdyString("\x00", 1)));
176 EXPECT_EQ(0x00u, DecodeValidUint32(4, "\xf0")); 174 EXPECT_EQ(0x00u, DecodeValidUint32(4, "\xf0"));
177 EXPECT_EQ(0x00u, DecodeValidUint32(3, string("\x00", 1))); 175 EXPECT_EQ(0x00u, DecodeValidUint32(3, SpdyString("\x00", 1)));
178 EXPECT_EQ(0x00u, DecodeValidUint32(3, "\xf8")); 176 EXPECT_EQ(0x00u, DecodeValidUint32(3, "\xf8"));
179 EXPECT_EQ(0x00u, DecodeValidUint32(2, string("\x00", 1))); 177 EXPECT_EQ(0x00u, DecodeValidUint32(2, SpdyString("\x00", 1)));
180 EXPECT_EQ(0x00u, DecodeValidUint32(2, "\xfc")); 178 EXPECT_EQ(0x00u, DecodeValidUint32(2, "\xfc"));
181 EXPECT_EQ(0x00u, DecodeValidUint32(1, string("\x00", 1))); 179 EXPECT_EQ(0x00u, DecodeValidUint32(1, SpdyString("\x00", 1)));
182 EXPECT_EQ(0x00u, DecodeValidUint32(1, "\xfe")); 180 EXPECT_EQ(0x00u, DecodeValidUint32(1, "\xfe"));
183 181
184 // Maximums. 182 // Maximums.
185 EXPECT_EQ(0x7eu, DecodeValidUint32(7, "\x7e")); 183 EXPECT_EQ(0x7eu, DecodeValidUint32(7, "\x7e"));
186 EXPECT_EQ(0x7eu, DecodeValidUint32(7, "\xfe")); 184 EXPECT_EQ(0x7eu, DecodeValidUint32(7, "\xfe"));
187 EXPECT_EQ(0x3eu, DecodeValidUint32(6, "\x3e")); 185 EXPECT_EQ(0x3eu, DecodeValidUint32(6, "\x3e"));
188 EXPECT_EQ(0x3eu, DecodeValidUint32(6, "\xfe")); 186 EXPECT_EQ(0x3eu, DecodeValidUint32(6, "\xfe"));
189 EXPECT_EQ(0x1eu, DecodeValidUint32(5, "\x1e")); 187 EXPECT_EQ(0x1eu, DecodeValidUint32(5, "\x1e"));
190 EXPECT_EQ(0x1eu, DecodeValidUint32(5, "\xfe")); 188 EXPECT_EQ(0x1eu, DecodeValidUint32(5, "\xfe"));
191 EXPECT_EQ(0x0eu, DecodeValidUint32(4, "\x0e")); 189 EXPECT_EQ(0x0eu, DecodeValidUint32(4, "\x0e"));
192 EXPECT_EQ(0x0eu, DecodeValidUint32(4, "\xfe")); 190 EXPECT_EQ(0x0eu, DecodeValidUint32(4, "\xfe"));
193 EXPECT_EQ(0x06u, DecodeValidUint32(3, "\x06")); 191 EXPECT_EQ(0x06u, DecodeValidUint32(3, "\x06"));
194 EXPECT_EQ(0x06u, DecodeValidUint32(3, "\xfe")); 192 EXPECT_EQ(0x06u, DecodeValidUint32(3, "\xfe"));
195 EXPECT_EQ(0x02u, DecodeValidUint32(2, "\x02")); 193 EXPECT_EQ(0x02u, DecodeValidUint32(2, "\x02"));
196 EXPECT_EQ(0x02u, DecodeValidUint32(2, "\xfe")); 194 EXPECT_EQ(0x02u, DecodeValidUint32(2, "\xfe"));
197 EXPECT_EQ(0x00u, DecodeValidUint32(1, string("\x00", 1))); 195 EXPECT_EQ(0x00u, DecodeValidUint32(1, SpdyString("\x00", 1)));
198 EXPECT_EQ(0x00u, DecodeValidUint32(1, "\xfe")); 196 EXPECT_EQ(0x00u, DecodeValidUint32(1, "\xfe"));
199 197
200 // Invalid. 198 // Invalid.
201 ExpectDecodeUint32Invalid(7, "\x7f"); 199 ExpectDecodeUint32Invalid(7, "\x7f");
202 ExpectDecodeUint32Invalid(7, "\xff"); 200 ExpectDecodeUint32Invalid(7, "\xff");
203 ExpectDecodeUint32Invalid(6, "\x3f"); 201 ExpectDecodeUint32Invalid(6, "\x3f");
204 ExpectDecodeUint32Invalid(6, "\xff"); 202 ExpectDecodeUint32Invalid(6, "\xff");
205 ExpectDecodeUint32Invalid(5, "\x1f"); 203 ExpectDecodeUint32Invalid(5, "\x1f");
206 ExpectDecodeUint32Invalid(5, "\xff"); 204 ExpectDecodeUint32Invalid(5, "\xff");
207 ExpectDecodeUint32Invalid(4, "\x0f"); 205 ExpectDecodeUint32Invalid(4, "\x0f");
208 ExpectDecodeUint32Invalid(4, "\xff"); 206 ExpectDecodeUint32Invalid(4, "\xff");
209 ExpectDecodeUint32Invalid(3, "\x07"); 207 ExpectDecodeUint32Invalid(3, "\x07");
210 ExpectDecodeUint32Invalid(3, "\xff"); 208 ExpectDecodeUint32Invalid(3, "\xff");
211 ExpectDecodeUint32Invalid(2, "\x03"); 209 ExpectDecodeUint32Invalid(2, "\x03");
212 ExpectDecodeUint32Invalid(2, "\xff"); 210 ExpectDecodeUint32Invalid(2, "\xff");
213 ExpectDecodeUint32Invalid(1, "\x01"); 211 ExpectDecodeUint32Invalid(1, "\x01");
214 ExpectDecodeUint32Invalid(1, "\xff"); 212 ExpectDecodeUint32Invalid(1, "\xff");
215 } 213 }
216 214
217 TEST(HpackInputStreamTest, TwoByteIntegersOneToSevenBitPrefixes) { 215 TEST(HpackInputStreamTest, TwoByteIntegersOneToSevenBitPrefixes) {
218 // Minimums. 216 // Minimums.
219 EXPECT_EQ(0x7fu, DecodeValidUint32(7, string("\x7f\x00", 2))); 217 EXPECT_EQ(0x7fu, DecodeValidUint32(7, SpdyString("\x7f\x00", 2)));
220 EXPECT_EQ(0x7fu, DecodeValidUint32(7, string("\xff\x00", 2))); 218 EXPECT_EQ(0x7fu, DecodeValidUint32(7, SpdyString("\xff\x00", 2)));
221 EXPECT_EQ(0x3fu, DecodeValidUint32(6, string("\x3f\x00", 2))); 219 EXPECT_EQ(0x3fu, DecodeValidUint32(6, SpdyString("\x3f\x00", 2)));
222 EXPECT_EQ(0x3fu, DecodeValidUint32(6, string("\xff\x00", 2))); 220 EXPECT_EQ(0x3fu, DecodeValidUint32(6, SpdyString("\xff\x00", 2)));
223 EXPECT_EQ(0x1fu, DecodeValidUint32(5, string("\x1f\x00", 2))); 221 EXPECT_EQ(0x1fu, DecodeValidUint32(5, SpdyString("\x1f\x00", 2)));
224 EXPECT_EQ(0x1fu, DecodeValidUint32(5, string("\xff\x00", 2))); 222 EXPECT_EQ(0x1fu, DecodeValidUint32(5, SpdyString("\xff\x00", 2)));
225 EXPECT_EQ(0x0fu, DecodeValidUint32(4, string("\x0f\x00", 2))); 223 EXPECT_EQ(0x0fu, DecodeValidUint32(4, SpdyString("\x0f\x00", 2)));
226 EXPECT_EQ(0x0fu, DecodeValidUint32(4, string("\xff\x00", 2))); 224 EXPECT_EQ(0x0fu, DecodeValidUint32(4, SpdyString("\xff\x00", 2)));
227 EXPECT_EQ(0x07u, DecodeValidUint32(3, string("\x07\x00", 2))); 225 EXPECT_EQ(0x07u, DecodeValidUint32(3, SpdyString("\x07\x00", 2)));
228 EXPECT_EQ(0x07u, DecodeValidUint32(3, string("\xff\x00", 2))); 226 EXPECT_EQ(0x07u, DecodeValidUint32(3, SpdyString("\xff\x00", 2)));
229 EXPECT_EQ(0x03u, DecodeValidUint32(2, string("\x03\x00", 2))); 227 EXPECT_EQ(0x03u, DecodeValidUint32(2, SpdyString("\x03\x00", 2)));
230 EXPECT_EQ(0x03u, DecodeValidUint32(2, string("\xff\x00", 2))); 228 EXPECT_EQ(0x03u, DecodeValidUint32(2, SpdyString("\xff\x00", 2)));
231 EXPECT_EQ(0x01u, DecodeValidUint32(1, string("\x01\x00", 2))); 229 EXPECT_EQ(0x01u, DecodeValidUint32(1, SpdyString("\x01\x00", 2)));
232 EXPECT_EQ(0x01u, DecodeValidUint32(1, string("\xff\x00", 2))); 230 EXPECT_EQ(0x01u, DecodeValidUint32(1, SpdyString("\xff\x00", 2)));
233 231
234 // Maximums. 232 // Maximums.
235 EXPECT_EQ(0xfeu, DecodeValidUint32(7, "\x7f\x7f")); 233 EXPECT_EQ(0xfeu, DecodeValidUint32(7, "\x7f\x7f"));
236 EXPECT_EQ(0xfeu, DecodeValidUint32(7, "\xff\x7f")); 234 EXPECT_EQ(0xfeu, DecodeValidUint32(7, "\xff\x7f"));
237 EXPECT_EQ(0xbeu, DecodeValidUint32(6, "\x3f\x7f")); 235 EXPECT_EQ(0xbeu, DecodeValidUint32(6, "\x3f\x7f"));
238 EXPECT_EQ(0xbeu, DecodeValidUint32(6, "\xff\x7f")); 236 EXPECT_EQ(0xbeu, DecodeValidUint32(6, "\xff\x7f"));
239 EXPECT_EQ(0x9eu, DecodeValidUint32(5, "\x1f\x7f")); 237 EXPECT_EQ(0x9eu, DecodeValidUint32(5, "\x1f\x7f"));
240 EXPECT_EQ(0x9eu, DecodeValidUint32(5, "\xff\x7f")); 238 EXPECT_EQ(0x9eu, DecodeValidUint32(5, "\xff\x7f"));
241 EXPECT_EQ(0x8eu, DecodeValidUint32(4, "\x0f\x7f")); 239 EXPECT_EQ(0x8eu, DecodeValidUint32(4, "\x0f\x7f"));
242 EXPECT_EQ(0x8eu, DecodeValidUint32(4, "\xff\x7f")); 240 EXPECT_EQ(0x8eu, DecodeValidUint32(4, "\xff\x7f"));
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // Set the length to be one more than it should be. 508 // Set the length to be one more than it should be.
511 HpackInputStream input_stream("\x0fstring literal"); 509 HpackInputStream input_stream("\x0fstring literal");
512 510
513 EXPECT_TRUE(input_stream.HasMoreData()); 511 EXPECT_TRUE(input_stream.HasMoreData());
514 SpdyStringPiece string_piece; 512 SpdyStringPiece string_piece;
515 EXPECT_FALSE(input_stream.DecodeNextIdentityString(&string_piece)); 513 EXPECT_FALSE(input_stream.DecodeNextIdentityString(&string_piece));
516 EXPECT_TRUE(input_stream.NeedMoreData()); 514 EXPECT_TRUE(input_stream.NeedMoreData());
517 } 515 }
518 516
519 TEST(HpackInputStreamTest, DecodeNextHuffmanString) { 517 TEST(HpackInputStreamTest, DecodeNextHuffmanString) {
520 string output, input(a2b_hex(kEncodedHuffmanFixture)); 518 SpdyString output, input(a2b_hex(kEncodedHuffmanFixture));
521 HpackInputStream input_stream(input); 519 HpackInputStream input_stream(input);
522 HpackInputStreamPeer input_stream_peer(&input_stream); 520 HpackInputStreamPeer input_stream_peer(&input_stream);
523 521
524 EXPECT_TRUE(input_stream.HasMoreData()); 522 EXPECT_TRUE(input_stream.HasMoreData());
525 EXPECT_TRUE(input_stream.DecodeNextHuffmanString(&output)); 523 EXPECT_TRUE(input_stream.DecodeNextHuffmanString(&output));
526 EXPECT_EQ(kDecodedHuffmanFixture, output); 524 EXPECT_EQ(kDecodedHuffmanFixture, output);
527 EXPECT_FALSE(input_stream.HasMoreData()); 525 EXPECT_FALSE(input_stream.HasMoreData());
528 EXPECT_FALSE(input_stream.NeedMoreData()); 526 EXPECT_FALSE(input_stream.NeedMoreData());
529 EXPECT_EQ(46u, input_stream_peer.ParsedBytesCurrent()); 527 EXPECT_EQ(46u, input_stream_peer.ParsedBytesCurrent());
530 } 528 }
531 529
532 TEST(HpackInputStreamTest, DecodeNextHuffmanStringNotEnoughInput) { 530 TEST(HpackInputStreamTest, DecodeNextHuffmanStringNotEnoughInput) {
533 string output, input(a2b_hex(kEncodedHuffmanFixture)); 531 SpdyString output, input(a2b_hex(kEncodedHuffmanFixture));
534 input[0]++; // Input prefix is one byte larger than available input. 532 input[0]++; // Input prefix is one byte larger than available input.
535 HpackInputStream input_stream(input); 533 HpackInputStream input_stream(input);
536 534
537 // Not enough buffer for declared encoded length. 535 // Not enough buffer for declared encoded length.
538 EXPECT_TRUE(input_stream.HasMoreData()); 536 EXPECT_TRUE(input_stream.HasMoreData());
539 EXPECT_FALSE(input_stream.DecodeNextHuffmanString(&output)); 537 EXPECT_FALSE(input_stream.DecodeNextHuffmanString(&output));
540 EXPECT_TRUE(input_stream.NeedMoreData()); 538 EXPECT_TRUE(input_stream.NeedMoreData());
541 } 539 }
542 540
543 TEST(HpackInputStreamTest, PeekBitsAndConsume) { 541 TEST(HpackInputStreamTest, PeekBitsAndConsume) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 752
755 HpackInputStream input_stream2("\x0e"); 753 HpackInputStream input_stream2("\x0e");
756 HpackInputStreamPeer input_stream2_peer(&input_stream2); 754 HpackInputStreamPeer input_stream2_peer(&input_stream2);
757 EXPECT_FALSE(input_stream2.DecodeNextIdentityString(&string_piece)); 755 EXPECT_FALSE(input_stream2.DecodeNextIdentityString(&string_piece));
758 // Only parsed first byte. 756 // Only parsed first byte.
759 EXPECT_EQ(1u, input_stream2_peer.ParsedBytesCurrent()); 757 EXPECT_EQ(1u, input_stream2_peer.ParsedBytesCurrent());
760 EXPECT_TRUE(input_stream2.NeedMoreData()); 758 EXPECT_TRUE(input_stream2.NeedMoreData());
761 } 759 }
762 760
763 TEST(HpackInputStreamTest, IncompleteHeaderDecodeNextHuffmanString) { 761 TEST(HpackInputStreamTest, IncompleteHeaderDecodeNextHuffmanString) {
764 string output, input(a2b_hex(kEncodedHuffmanFixture)); 762 SpdyString output, input(a2b_hex(kEncodedHuffmanFixture));
765 input.resize(input.size() - 1); // Remove last byte. 763 input.resize(input.size() - 1); // Remove last byte.
766 HpackInputStream input_stream1(input); 764 HpackInputStream input_stream1(input);
767 HpackInputStreamPeer input_stream1_peer(&input_stream1); 765 HpackInputStreamPeer input_stream1_peer(&input_stream1);
768 EXPECT_FALSE(input_stream1.DecodeNextHuffmanString(&output)); 766 EXPECT_FALSE(input_stream1.DecodeNextHuffmanString(&output));
769 EXPECT_EQ(1u, input_stream1_peer.ParsedBytesCurrent()); 767 EXPECT_EQ(1u, input_stream1_peer.ParsedBytesCurrent());
770 EXPECT_TRUE(input_stream1.NeedMoreData()); 768 EXPECT_TRUE(input_stream1.NeedMoreData());
771 769
772 input.erase(1, input.size()); // Remove all bytes except the first one. 770 input.erase(1, input.size()); // Remove all bytes except the first one.
773 HpackInputStream input_stream2(input); 771 HpackInputStream input_stream2(input);
774 HpackInputStreamPeer input_stream2_peer(&input_stream2); 772 HpackInputStreamPeer input_stream2_peer(&input_stream2);
775 EXPECT_FALSE(input_stream2.DecodeNextHuffmanString(&output)); 773 EXPECT_FALSE(input_stream2.DecodeNextHuffmanString(&output));
776 EXPECT_EQ(1u, input_stream2_peer.ParsedBytesCurrent()); 774 EXPECT_EQ(1u, input_stream2_peer.ParsedBytesCurrent());
777 EXPECT_TRUE(input_stream2.NeedMoreData()); 775 EXPECT_TRUE(input_stream2.NeedMoreData());
778 } 776 }
779 777
780 } // namespace test 778 } // namespace test
781 779
782 } // namespace net 780 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_input_stream.cc ('k') | net/spdy/hpack/hpack_output_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698