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

Side by Side Diff: net/spdy/hpack_huffman_table_test.cc

Issue 980393003: Remove some dead code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert removal of DebugLogTableState() definition. Created 5 years, 9 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_encoder_test.cc ('k') | net/spdy/spdy_framer.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_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"
11 #include "net/spdy/hpack_constants.h" 11 #include "net/spdy/hpack_constants.h"
12 #include "net/spdy/hpack_input_stream.h" 12 #include "net/spdy/hpack_input_stream.h"
13 #include "net/spdy/hpack_output_stream.h" 13 #include "net/spdy/hpack_output_stream.h"
14 #include "net/spdy/spdy_test_utils.h" 14 #include "net/spdy/spdy_test_utils.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 using base::StringPiece; 18 using base::StringPiece;
19 using net::test::a2b_hex; 19 using net::test::a2b_hex;
20 using std::string; 20 using std::string;
21 using testing::ElementsAre;
22 using testing::ElementsAreArray; 21 using testing::ElementsAreArray;
23 using testing::Pointwise; 22 using testing::Pointwise;
24 23
25 namespace net { 24 namespace net {
26 25
27 namespace test { 26 namespace test {
28 27
29 typedef HpackHuffmanTable::DecodeEntry DecodeEntry; 28 typedef HpackHuffmanTable::DecodeEntry DecodeEntry;
30 typedef HpackHuffmanTable::DecodeTable DecodeTable; 29 typedef HpackHuffmanTable::DecodeTable DecodeTable;
31 30
(...skipping 16 matching lines...) Expand all
48 return static_cast<char>(table_.pad_bits_); 47 return static_cast<char>(table_.pad_bits_);
49 } 48 }
50 uint16 failed_symbol_id() const { 49 uint16 failed_symbol_id() const {
51 return table_.failed_symbol_id_; 50 return table_.failed_symbol_id_;
52 } 51 }
53 std::vector<DecodeEntry> decode_entries(const DecodeTable& decode_table) { 52 std::vector<DecodeEntry> decode_entries(const DecodeTable& decode_table) {
54 std::vector<DecodeEntry>::const_iterator begin = 53 std::vector<DecodeEntry>::const_iterator begin =
55 table_.decode_entries_.begin() + decode_table.entries_offset; 54 table_.decode_entries_.begin() + decode_table.entries_offset;
56 return std::vector<DecodeEntry>(begin, begin + decode_table.size()); 55 return std::vector<DecodeEntry>(begin, begin + decode_table.size());
57 } 56 }
58 void DumpDecodeTable(const DecodeTable& table) {
59 std::vector<DecodeEntry> entries = decode_entries(table);
60 LOG(INFO) << "Table size " << (1 << table.indexed_length)
61 << " prefix " << unsigned(table.prefix_length)
62 << " indexed " << unsigned(table.indexed_length);
63 size_t i = 0;
64 while (i != table.size()) {
65 const DecodeEntry& entry = entries[i];
66 LOG(INFO) << i << ":"
67 << " next_table " << unsigned(entry.next_table_index)
68 << " length " << unsigned(entry.length)
69 << " symbol " << unsigned(entry.symbol_id);
70 size_t j = 1;
71 for (; (i + j) != table.size(); j++) {
72 const DecodeEntry& next = entries[i + j];
73 if (next.next_table_index != entry.next_table_index ||
74 next.length != entry.length ||
75 next.symbol_id != entry.symbol_id)
76 break;
77 }
78 if (j > 1) {
79 LOG(INFO) << " (repeats " << j << " times)";
80 }
81 i += j;
82 }
83 }
84 57
85 private: 58 private:
86 const HpackHuffmanTable& table_; 59 const HpackHuffmanTable& table_;
87 }; 60 };
88 61
89 namespace { 62 namespace {
90 63
91 class HpackHuffmanTableTest : public ::testing::Test { 64 class HpackHuffmanTableTest : public ::testing::Test {
92 protected: 65 protected:
93 HpackHuffmanTableTest() 66 HpackHuffmanTableTest()
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 output_stream.TakeString(&encoding); 479 output_stream.TakeString(&encoding);
507 EXPECT_EQ(encoding.size(), table_.EncodedSize(test_table[i])); 480 EXPECT_EQ(encoding.size(), table_.EncodedSize(test_table[i]));
508 } 481 }
509 } 482 }
510 483
511 } // namespace 484 } // namespace
512 485
513 } // namespace test 486 } // namespace test
514 487
515 } // namespace net 488 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack_encoder_test.cc ('k') | net/spdy/spdy_framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698