blob: 1a43c9848d7a536cb83e47b719bd8a3f4daad5d1 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "spdy/core/hpack/hpack_entry.h"
#include "absl/hash/hash.h"
#include "common/platform/api/quiche_test.h"
namespace spdy {
namespace {
TEST(HpackLookupEntryTest, EntryNamesDiffer) {
HpackLookupEntry entry1{"header", "value"};
HpackLookupEntry entry2{"HEADER", "value"};
EXPECT_FALSE(entry1 == entry2);
EXPECT_NE(absl::Hash<HpackLookupEntry>()(entry1),
absl::Hash<HpackLookupEntry>()(entry2));
}
TEST(HpackLookupEntryTest, EntryValuesDiffer) {
HpackLookupEntry entry1{"header", "value"};
HpackLookupEntry entry2{"header", "VALUE"};
EXPECT_FALSE(entry1 == entry2);
EXPECT_NE(absl::Hash<HpackLookupEntry>()(entry1),
absl::Hash<HpackLookupEntry>()(entry2));
}
TEST(HpackLookupEntryTest, EntriesEqual) {
HpackLookupEntry entry1{"name", "value"};
HpackLookupEntry entry2{"name", "value"};
EXPECT_TRUE(entry1 == entry2);
EXPECT_EQ(absl::Hash<HpackLookupEntry>()(entry1),
absl::Hash<HpackLookupEntry>()(entry2));
}
TEST(HpackEntryTest, BasicEntry) {
HpackEntry entry("header-name", "header value");
EXPECT_EQ("header-name", entry.name());
EXPECT_EQ("header value", entry.value());
EXPECT_EQ(55u, entry.Size());
EXPECT_EQ(55u, HpackEntry::Size("header-name", "header value"));
}
TEST(HpackEntryTest, DefaultConstructor) {
HpackEntry entry;
EXPECT_TRUE(entry.name().empty());
EXPECT_TRUE(entry.value().empty());
EXPECT_EQ(32u, entry.Size());
EXPECT_EQ(32u, HpackEntry::Size("", ""));
}
} // namespace
} // namespace spdy