OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/spdy/hpack/hpack_static_table.h" | |
6 | |
7 #include <set> | |
8 #include <vector> | |
9 | |
10 #include "net/spdy/hpack/hpack_constants.h" | |
11 #include "net/spdy/platform/api/spdy_string_piece.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | |
14 namespace net { | |
15 | |
16 namespace test { | |
17 | |
18 namespace { | |
19 | |
20 class HpackStaticTableTest : public ::testing::Test { | |
21 protected: | |
22 HpackStaticTableTest() : table_() {} | |
23 | |
24 HpackStaticTable table_; | |
25 }; | |
26 | |
27 // Check that an initialized instance has the right number of entries. | |
28 TEST_F(HpackStaticTableTest, Initialize) { | |
29 EXPECT_FALSE(table_.IsInitialized()); | |
30 std::vector<HpackStaticEntry> static_table = HpackStaticTableVector(); | |
31 table_.Initialize(&static_table[0], static_table.size()); | |
32 EXPECT_TRUE(table_.IsInitialized()); | |
33 | |
34 HpackHeaderTable::EntryTable static_entries = table_.GetStaticEntries(); | |
35 EXPECT_EQ(static_table.size(), static_entries.size()); | |
36 | |
37 HpackHeaderTable::UnorderedEntrySet static_index = table_.GetStaticIndex(); | |
38 EXPECT_EQ(static_table.size(), static_index.size()); | |
39 | |
40 HpackHeaderTable::NameToEntryMap static_name_index = | |
41 table_.GetStaticNameIndex(); | |
42 std::set<SpdyStringPiece> names; | |
43 for (auto* entry : static_index) { | |
44 names.insert(entry->name()); | |
45 } | |
46 EXPECT_EQ(names.size(), static_name_index.size()); | |
47 } | |
48 | |
49 // Test that ObtainHpackStaticTable returns the same instance every time. | |
50 TEST_F(HpackStaticTableTest, IsSingleton) { | |
51 const HpackStaticTable* static_table_one = &ObtainHpackStaticTable(); | |
52 const HpackStaticTable* static_table_two = &ObtainHpackStaticTable(); | |
53 EXPECT_EQ(static_table_one, static_table_two); | |
54 } | |
55 | |
56 } // namespace | |
57 | |
58 } // namespace test | |
59 | |
60 } // namespace net | |
OLD | NEW |