OLD | NEW |
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_huffman_table.h" | 5 #include "net/spdy/hpack_huffman_table.h" |
6 | 6 |
7 #include <bitset> | 7 #include <bitset> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 HpackHuffmanSymbol code[] = { | 231 HpackHuffmanSymbol code[] = { |
232 {bits32("01100000000000000000000000000000"), 4, 0}, // 3rd. | 232 {bits32("01100000000000000000000000000000"), 4, 0}, // 3rd. |
233 {bits32("01110000000000000000000000000000"), 4, 1}, // 4th. | 233 {bits32("01110000000000000000000000000000"), 4, 1}, // 4th. |
234 {bits32("00000000000000000000000000000000"), 2, 2}, // 1st assigned code. | 234 {bits32("00000000000000000000000000000000"), 2, 2}, // 1st assigned code. |
235 {bits32("01000000000000000000000000000000"), 3, 3}, // 2nd. | 235 {bits32("01000000000000000000000000000000"), 3, 3}, // 2nd. |
236 {bits32("10000000000000000000000000000000"), 5, 4}, // 5th. | 236 {bits32("10000000000000000000000000000000"), 5, 4}, // 5th. |
237 {bits32("10001000000000000000000000000000"), 5, 5}, // 6th. | 237 {bits32("10001000000000000000000000000000"), 5, 5}, // 6th. |
238 {bits32("10011000000000000000000000000000"), 8, 6}, // 8th. | 238 {bits32("10011000000000000000000000000000"), 8, 6}, // 8th. |
239 {bits32("10010000000000000000000000000000"), 5, 7}}; // 7th. | 239 {bits32("10010000000000000000000000000000"), 5, 7}}; // 7th. |
240 EXPECT_TRUE(table_.Initialize(code, arraysize(code))); | 240 EXPECT_TRUE(table_.Initialize(code, arraysize(code))); |
241 | 241 ASSERT_EQ(arraysize(code), peer_.code_by_id().size()); |
242 EXPECT_THAT(peer_.code_by_id(), ElementsAre( | 242 ASSERT_EQ(arraysize(code), peer_.length_by_id().size()); |
243 bits32("01100000000000000000000000000000"), | 243 for (size_t i = 0; i < arraysize(code); ++i) { |
244 bits32("01110000000000000000000000000000"), | 244 EXPECT_EQ(code[i].code, peer_.code_by_id()[i]); |
245 bits32("00000000000000000000000000000000"), | 245 EXPECT_EQ(code[i].length, peer_.length_by_id()[i]); |
246 bits32("01000000000000000000000000000000"), | 246 } |
247 bits32("10000000000000000000000000000000"), | |
248 bits32("10001000000000000000000000000000"), | |
249 bits32("10011000000000000000000000000000"), | |
250 bits32("10010000000000000000000000000000"))); | |
251 EXPECT_THAT(peer_.length_by_id(), ElementsAre( | |
252 4, 4, 2, 3, 5, 5, 8, 5)); | |
253 | 247 |
254 EXPECT_EQ(1u, peer_.decode_tables().size()); | 248 EXPECT_EQ(1u, peer_.decode_tables().size()); |
255 { | 249 { |
256 std::vector<DecodeEntry> expected; | 250 std::vector<DecodeEntry> expected; |
257 expected.resize(128, DecodeEntry(0, 2, 2)); // Fills 128. | 251 expected.resize(128, DecodeEntry(0, 2, 2)); // Fills 128. |
258 expected.resize(192, DecodeEntry(0, 3, 3)); // Fills 64. | 252 expected.resize(192, DecodeEntry(0, 3, 3)); // Fills 64. |
259 expected.resize(224, DecodeEntry(0, 4, 0)); // Fills 32. | 253 expected.resize(224, DecodeEntry(0, 4, 0)); // Fills 32. |
260 expected.resize(256, DecodeEntry(0, 4, 1)); // Fills 32. | 254 expected.resize(256, DecodeEntry(0, 4, 1)); // Fills 32. |
261 expected.resize(272, DecodeEntry(0, 5, 4)); // Fills 16. | 255 expected.resize(272, DecodeEntry(0, 5, 4)); // Fills 16. |
262 expected.resize(288, DecodeEntry(0, 5, 5)); // Fills 16. | 256 expected.resize(288, DecodeEntry(0, 5, 5)); // Fills 16. |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 output_stream.TakeString(&encoding); | 506 output_stream.TakeString(&encoding); |
513 EXPECT_EQ(encoding.size(), table_.EncodedSize(test_table[i])); | 507 EXPECT_EQ(encoding.size(), table_.EncodedSize(test_table[i])); |
514 } | 508 } |
515 } | 509 } |
516 | 510 |
517 } // namespace | 511 } // namespace |
518 | 512 |
519 } // namespace test | 513 } // namespace test |
520 | 514 |
521 } // namespace net | 515 } // namespace net |
OLD | NEW |