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_static_table.h" 6 7#include <vector> 8 9#include "net/base/net_export.h" 10#include "net/spdy/hpack_constants.h" 11#include "testing/gtest/include/gtest/gtest.h" 12 13namespace net { 14 15namespace test { 16 17namespace { 18 19class HpackStaticTableTest : public ::testing::Test { 20 protected: 21 HpackStaticTableTest() : table_() {} 22 23 HpackStaticTable table_; 24}; 25 26// Check that an initialized instance has the right number of entries. 27TEST_F(HpackStaticTableTest, Initialize) { 28 EXPECT_FALSE(table_.IsInitialized()); 29 std::vector<HpackStaticEntry> static_table = HpackStaticTableVector(); 30 table_.Initialize(&static_table[0], static_table.size()); 31 EXPECT_TRUE(table_.IsInitialized()); 32 33 HpackHeaderTable::EntryTable static_entries = table_.GetStaticEntries(); 34 EXPECT_EQ(static_table.size(), static_entries.size()); 35 36 HpackHeaderTable::OrderedEntrySet static_index = table_.GetStaticIndex(); 37 EXPECT_EQ(static_table.size(), static_index.size()); 38} 39 40// Test that ObtainHpackStaticTable returns the same instance every time. 41TEST_F(HpackStaticTableTest, IsSingleton) { 42 const HpackStaticTable* static_table_one = &ObtainHpackStaticTable(); 43 const HpackStaticTable* static_table_two = &ObtainHpackStaticTable(); 44 EXPECT_EQ(static_table_one, static_table_two); 45} 46 47} // namespace 48 49} // namespace test 50 51} // namespace net 52