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 "quiche/spdy/core/hpack/hpack_entry.h"
6
7 #include "absl/hash/hash.h"
8 #include "quiche/common/platform/api/quiche_test.h"
9
10 namespace spdy {
11
12 namespace {
13
TEST(HpackLookupEntryTest,EntryNamesDiffer)14 TEST(HpackLookupEntryTest, EntryNamesDiffer) {
15 HpackLookupEntry entry1{"header", "value"};
16 HpackLookupEntry entry2{"HEADER", "value"};
17
18 EXPECT_FALSE(entry1 == entry2);
19 EXPECT_NE(absl::Hash<HpackLookupEntry>()(entry1),
20 absl::Hash<HpackLookupEntry>()(entry2));
21 }
22
TEST(HpackLookupEntryTest,EntryValuesDiffer)23 TEST(HpackLookupEntryTest, EntryValuesDiffer) {
24 HpackLookupEntry entry1{"header", "value"};
25 HpackLookupEntry entry2{"header", "VALUE"};
26
27 EXPECT_FALSE(entry1 == entry2);
28 EXPECT_NE(absl::Hash<HpackLookupEntry>()(entry1),
29 absl::Hash<HpackLookupEntry>()(entry2));
30 }
31
TEST(HpackLookupEntryTest,EntriesEqual)32 TEST(HpackLookupEntryTest, EntriesEqual) {
33 HpackLookupEntry entry1{"name", "value"};
34 HpackLookupEntry entry2{"name", "value"};
35
36 EXPECT_TRUE(entry1 == entry2);
37 EXPECT_EQ(absl::Hash<HpackLookupEntry>()(entry1),
38 absl::Hash<HpackLookupEntry>()(entry2));
39 }
40
TEST(HpackEntryTest,BasicEntry)41 TEST(HpackEntryTest, BasicEntry) {
42 HpackEntry entry("header-name", "header value");
43
44 EXPECT_EQ("header-name", entry.name());
45 EXPECT_EQ("header value", entry.value());
46
47 EXPECT_EQ(55u, entry.Size());
48 EXPECT_EQ(55u, HpackEntry::Size("header-name", "header value"));
49 }
50
51 } // namespace
52
53 } // namespace spdy
54