ID
stringlengths 36
36
| Language
stringclasses 1
value | Repository Name
stringclasses 13
values | File Name
stringlengths 2
44
| File Path in Repository
stringlengths 11
111
| File Path for Unit Test
stringlengths 16
116
| Code
stringlengths 0
278k
| Unit Test - (Ground Truth)
stringlengths 127
663k
| Code Url
stringlengths 91
198
| Test Code Url
stringlengths 96
203
| Commit Hash
stringclasses 13
values |
---|---|---|---|---|---|---|---|---|---|---|
683091d0-4b5c-4f95-8c5d-18017a2e0324 | cpp | google/quiche | qpack_header_table | quiche/quic/core/qpack/qpack_header_table.cc | quiche/quic/core/qpack/qpack_header_table_test.cc | #include "quiche/quic/core/qpack/qpack_header_table.h"
#include <utility>
#include "absl/strings/string_view.h"
#include "quiche/quic/core/qpack/qpack_static_table.h"
#include "quiche/quic/platform/api/quic_logging.h"
#include "quiche/common/platform/api/quiche_logging.h"
namespace quic {
QpackEncoderHeaderTable::QpackEncoderHeaderTable()
: static_index_(ObtainQpackStaticTable().GetStaticIndex()),
static_name_index_(ObtainQpackStaticTable().GetStaticNameIndex()) {}
uint64_t QpackEncoderHeaderTable::InsertEntry(absl::string_view name,
absl::string_view value) {
const uint64_t index =
QpackHeaderTableBase<QpackEncoderDynamicTable>::InsertEntry(name, value);
name = dynamic_entries().back()->name();
value = dynamic_entries().back()->value();
auto index_result = dynamic_index_.insert(
std::make_pair(QpackLookupEntry{name, value}, index));
if (!index_result.second) {
QUICHE_DCHECK_GT(index, index_result.first->second);
dynamic_index_.erase(index_result.first);
auto result = dynamic_index_.insert(
std::make_pair(QpackLookupEntry{name, value}, index));
QUICHE_CHECK(result.second);
}
auto name_result = dynamic_name_index_.insert({name, index});
if (!name_result.second) {
QUICHE_DCHECK_GT(index, name_result.first->second);
dynamic_name_index_.erase(name_result.first);
auto result = dynamic_name_index_.insert({name, index});
QUICHE_CHECK(result.second);
}
return index;
}
QpackEncoderHeaderTable::MatchResult QpackEncoderHeaderTable::FindHeaderField(
absl::string_view name, absl::string_view value) const {
QpackLookupEntry query{name, value};
auto index_it = static_index_.find(query);
if (index_it != static_index_.end()) {
return { MatchType::kNameAndValue,
true,
index_it->second};
}
index_it = dynamic_index_.find(query);
if (index_it != dynamic_index_.end()) {
return { MatchType::kNameAndValue,
false,
index_it->second};
}
return FindHeaderName(name);
}
QpackEncoderHeaderTable::MatchResult QpackEncoderHeaderTable::FindHeaderName(
absl::string_view name) const {
auto name_index_it = static_name_index_.find(name);
if (name_index_it != static_name_index_.end()) {
return { MatchType::kName,
true,
name_index_it->second};
}
name_index_it = dynamic_name_index_.find(name);
if (name_index_it != dynamic_name_index_.end()) {
return { MatchType::kName,
false,
name_index_it->second};
}
return { MatchType::kNoMatch,
false,
0};
}
uint64_t QpackEncoderHeaderTable::MaxInsertSizeWithoutEvictingGivenEntry(
uint64_t index) const {
QUICHE_DCHECK_LE(dropped_entry_count(), index);
if (index > inserted_entry_count()) {
return dynamic_table_capacity();
}
uint64_t max_insert_size = dynamic_table_capacity() - dynamic_table_size();
uint64_t entry_index = dropped_entry_count();
for (const auto& entry : dynamic_entries()) {
if (entry_index >= index) {
break;
}
++entry_index;
max_insert_size += entry->Size();
}
return max_insert_size;
}
uint64_t QpackEncoderHeaderTable::draining_index(
float draining_fraction) const {
QUICHE_DCHECK_LE(0.0, draining_fraction);
QUICHE_DCHECK_LE(draining_fraction, 1.0);
const uint64_t required_space = draining_fraction * dynamic_table_capacity();
uint64_t space_above_draining_index =
dynamic_table_capacity() - dynamic_table_size();
if (dynamic_entries().empty() ||
space_above_draining_index >= required_space) {
return dropped_entry_count();
}
auto it = dynamic_entries().begin();
uint64_t entry_index = dropped_entry_count();
while (space_above_draining_index < required_space) {
space_above_draining_index += (*it)->Size();
++it;
++entry_index;
if (it == dynamic_entries().end()) {
return inserted_entry_count();
}
}
return entry_index;
}
void QpackEncoderHeaderTable::RemoveEntryFromEnd() {
const QpackEntry* const entry = dynamic_entries().front().get();
const uint64_t index = dropped_entry_count();
auto index_it = dynamic_index_.find({entry->name(), entry->value()});
if (index_it != dynamic_index_.end() && index_it->second == index) {
dynamic_index_.erase(index_it);
}
auto name_it = dynamic_name_index_.find(entry->name());
if (name_it != dynamic_name_index_.end() && name_it->second == index) {
dynamic_name_index_.erase(name_it);
}
QpackHeaderTableBase<QpackEncoderDynamicTable>::RemoveEntryFromEnd();
}
QpackDecoderHeaderTable::QpackDecoderHeaderTable()
: static_entries_(ObtainQpackStaticTable().GetStaticEntries()) {}
QpackDecoderHeaderTable::~QpackDecoderHeaderTable() {
for (auto& entry : observers_) {
entry.second->Cancel();
}
}
uint64_t QpackDecoderHeaderTable::InsertEntry(absl::string_view name,
absl::string_view value) {
const uint64_t index =
QpackHeaderTableBase<QpackDecoderDynamicTable>::InsertEntry(name, value);
while (!observers_.empty()) {
auto it = observers_.begin();
if (it->first > inserted_entry_count()) {
break;
}
Observer* observer = it->second;
observers_.erase(it);
observer->OnInsertCountReachedThreshold();
}
return index;
}
const QpackEntry* QpackDecoderHeaderTable::LookupEntry(bool is_static,
uint64_t index) const {
if (is_static) {
if (index >= static_entries_.size()) {
return nullptr;
}
return &static_entries_[index];
}
if (index < dropped_entry_count()) {
return nullptr;
}
index -= dropped_entry_count();
if (index >= dynamic_entries().size()) {
return nullptr;
}
return &dynamic_entries()[index];
}
void QpackDecoderHeaderTable::RegisterObserver(uint64_t required_insert_count,
Observer* observer) {
QUICHE_DCHECK_GT(required_insert_count, 0u);
observers_.insert({required_insert_count, observer});
}
void QpackDecoderHeaderTable::UnregisterObserver(uint64_t required_insert_count,
Observer* observer) {
auto it = observers_.lower_bound(required_insert_count);
while (it != observers_.end() && it->first == required_insert_count) {
if (it->second == observer) {
observers_.erase(it);
return;
}
++it;
}
QUICHE_NOTREACHED();
}
} | #include "quiche/quic/core/qpack/qpack_header_table.h"
#include <memory>
#include <tuple>
#include <utility>
#include "absl/base/macros.h"
#include "absl/strings/string_view.h"
#include "quiche/http2/hpack/hpack_entry.h"
#include "quiche/quic/core/qpack/qpack_static_table.h"
#include "quiche/quic/platform/api/quic_test.h"
namespace quic {
namespace test {
namespace {
using ::testing::_;
using ::testing::FieldsAre;
using ::testing::Mock;
using ::testing::StrictMock;
constexpr uint64_t kMaximumDynamicTableCapacityForTesting = 1024 * 1024;
constexpr bool kStaticEntry = true;
constexpr bool kDynamicEntry = false;
template <typename T>
class QpackHeaderTableTest : public QuicTest {
protected:
~QpackHeaderTableTest() override = default;
void SetUp() override {
ASSERT_TRUE(table_.SetMaximumDynamicTableCapacity(
kMaximumDynamicTableCapacityForTesting));
ASSERT_TRUE(
table_.SetDynamicTableCapacity(kMaximumDynamicTableCapacityForTesting));
}
bool EntryFitsDynamicTableCapacity(absl::string_view name,
absl::string_view value) const {
return table_.EntryFitsDynamicTableCapacity(name, value);
}
void InsertEntry(absl::string_view name, absl::string_view value) {
table_.InsertEntry(name, value);
}
bool SetDynamicTableCapacity(uint64_t capacity) {
return table_.SetDynamicTableCapacity(capacity);
}
uint64_t max_entries() const { return table_.max_entries(); }
uint64_t inserted_entry_count() const {
return table_.inserted_entry_count();
}
uint64_t dropped_entry_count() const { return table_.dropped_entry_count(); }
T table_;
};
using MyTypes =
::testing::Types<QpackEncoderHeaderTable, QpackDecoderHeaderTable>;
TYPED_TEST_SUITE(QpackHeaderTableTest, MyTypes);
TYPED_TEST(QpackHeaderTableTest, MaxEntries) {
TypeParam table1;
table1.SetMaximumDynamicTableCapacity(1024);
EXPECT_EQ(32u, table1.max_entries());
TypeParam table2;
table2.SetMaximumDynamicTableCapacity(500);
EXPECT_EQ(15u, table2.max_entries());
}
TYPED_TEST(QpackHeaderTableTest, SetDynamicTableCapacity) {
EXPECT_TRUE(this->SetDynamicTableCapacity(1024));
EXPECT_EQ(32u * 1024, this->max_entries());
EXPECT_TRUE(this->SetDynamicTableCapacity(500));
EXPECT_EQ(32u * 1024, this->max_entries());
EXPECT_FALSE(this->SetDynamicTableCapacity(
2 * kMaximumDynamicTableCapacityForTesting));
}
TYPED_TEST(QpackHeaderTableTest, EntryFitsDynamicTableCapacity) {
EXPECT_TRUE(this->SetDynamicTableCapacity(39));
EXPECT_TRUE(this->EntryFitsDynamicTableCapacity("foo", "bar"));
EXPECT_TRUE(this->EntryFitsDynamicTableCapacity("foo", "bar2"));
EXPECT_FALSE(this->EntryFitsDynamicTableCapacity("foo", "bar12"));
}
class QpackEncoderHeaderTableTest
: public QpackHeaderTableTest<QpackEncoderHeaderTable> {
protected:
enum MatchType { kNameAndValue, kName, kNoMatch };
~QpackEncoderHeaderTableTest() override = default;
std::tuple<MatchType, bool, uint64_t> FindHeaderField(
absl::string_view name, absl::string_view value) const {
QpackEncoderHeaderTable::MatchResult match_result =
table_.FindHeaderField(name, value);
return {static_cast<MatchType>(match_result.match_type),
match_result.is_static, match_result.index};
}
std::tuple<MatchType, bool, uint64_t> FindHeaderName(
absl::string_view name) const {
QpackEncoderHeaderTable::MatchResult match_result =
table_.FindHeaderName(name);
return {static_cast<MatchType>(match_result.match_type),
match_result.is_static, match_result.index};
}
uint64_t MaxInsertSizeWithoutEvictingGivenEntry(uint64_t index) const {
return table_.MaxInsertSizeWithoutEvictingGivenEntry(index);
}
uint64_t draining_index(float draining_fraction) const {
return table_.draining_index(draining_fraction);
}
};
TEST_F(QpackEncoderHeaderTableTest, FindStaticHeaderField) {
EXPECT_THAT(FindHeaderField(":method", "GET"),
FieldsAre(kNameAndValue, kStaticEntry, 17u));
EXPECT_THAT(FindHeaderField(":method", "POST"),
FieldsAre(kNameAndValue, kStaticEntry, 20u));
EXPECT_THAT(FindHeaderField(":method", "TRACE"),
FieldsAre(kName, kStaticEntry, 15u));
EXPECT_THAT(FindHeaderName(":method"), FieldsAre(kName, kStaticEntry, 15u));
EXPECT_THAT(FindHeaderField("accept-encoding", "gzip, deflate, br"),
FieldsAre(kNameAndValue, kStaticEntry, 31u));
EXPECT_THAT(FindHeaderField("accept-encoding", "compress"),
FieldsAre(kName, kStaticEntry, 31u));
EXPECT_THAT(FindHeaderField("accept-encoding", ""),
FieldsAre(kName, kStaticEntry, 31u));
EXPECT_THAT(FindHeaderName("accept-encoding"),
FieldsAre(kName, kStaticEntry, 31u));
EXPECT_THAT(FindHeaderField("location", ""),
FieldsAre(kNameAndValue, kStaticEntry, 12u));
EXPECT_THAT(FindHeaderField("location", "foo"),
FieldsAre(kName, kStaticEntry, 12u));
EXPECT_THAT(FindHeaderName("location"), FieldsAre(kName, kStaticEntry, 12u));
EXPECT_THAT(FindHeaderField("foo", ""), FieldsAre(kNoMatch, _, _));
EXPECT_THAT(FindHeaderField("foo", "bar"), FieldsAre(kNoMatch, _, _));
EXPECT_THAT(FindHeaderName("foo"), FieldsAre(kNoMatch, _, _));
}
TEST_F(QpackEncoderHeaderTableTest, FindDynamicHeaderField) {
EXPECT_THAT(FindHeaderField("foo", "bar"), FieldsAre(kNoMatch, _, _));
EXPECT_THAT(FindHeaderField("foo", "baz"), FieldsAre(kNoMatch, _, _));
EXPECT_THAT(FindHeaderName("foo"), FieldsAre(kNoMatch, _, _));
InsertEntry("foo", "bar");
EXPECT_THAT(FindHeaderField("foo", "bar"),
FieldsAre(kNameAndValue, kDynamicEntry, 0u));
EXPECT_THAT(FindHeaderField("foo", "baz"),
FieldsAre(kName, kDynamicEntry, 0u));
EXPECT_THAT(FindHeaderName("foo"), FieldsAre(kName, kDynamicEntry, 0u));
InsertEntry("foo", "bar");
EXPECT_THAT(FindHeaderField("foo", "bar"),
FieldsAre(kNameAndValue, kDynamicEntry, 1u));
EXPECT_THAT(FindHeaderField("foo", "baz"),
FieldsAre(kName, kDynamicEntry, 1u));
EXPECT_THAT(FindHeaderName("foo"), FieldsAre(kName, kDynamicEntry, 1u));
}
TEST_F(QpackEncoderHeaderTableTest, FindHeaderFieldPrefersStaticTable) {
InsertEntry(":method", "GET");
EXPECT_THAT(FindHeaderField(":method", "GET"),
FieldsAre(kNameAndValue, kStaticEntry, 17u));
EXPECT_THAT(FindHeaderField(":method", "TRACE"),
FieldsAre(kName, kStaticEntry, 15u));
EXPECT_THAT(FindHeaderName(":method"), FieldsAre(kName, kStaticEntry, 15u));
InsertEntry(":method", "TRACE");
EXPECT_THAT(FindHeaderField(":method", "TRACE"),
FieldsAre(kNameAndValue, kDynamicEntry, 1u));
}
TEST_F(QpackEncoderHeaderTableTest, EvictByInsertion) {
EXPECT_TRUE(SetDynamicTableCapacity(40));
InsertEntry("foo", "bar");
EXPECT_EQ(1u, inserted_entry_count());
EXPECT_EQ(0u, dropped_entry_count());
EXPECT_THAT(FindHeaderField("foo", "bar"),
FieldsAre(kNameAndValue, kDynamicEntry, 0u));
InsertEntry("baz", "qux");
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(1u, dropped_entry_count());
EXPECT_THAT(FindHeaderField("foo", "bar"), FieldsAre(kNoMatch, _, _));
EXPECT_THAT(FindHeaderField("baz", "qux"),
FieldsAre(kNameAndValue, kDynamicEntry, 1u));
}
TEST_F(QpackEncoderHeaderTableTest, EvictByUpdateTableSize) {
InsertEntry("foo", "bar");
InsertEntry("baz", "qux");
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(0u, dropped_entry_count());
EXPECT_THAT(FindHeaderField("foo", "bar"),
FieldsAre(kNameAndValue, kDynamicEntry, 0u));
EXPECT_THAT(FindHeaderField("baz", "qux"),
FieldsAre(kNameAndValue, kDynamicEntry, 1u));
EXPECT_TRUE(SetDynamicTableCapacity(40));
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(1u, dropped_entry_count());
EXPECT_THAT(FindHeaderField("foo", "bar"), FieldsAre(kNoMatch, _, _));
EXPECT_THAT(FindHeaderField("baz", "qux"),
FieldsAre(kNameAndValue, kDynamicEntry, 1u));
EXPECT_TRUE(SetDynamicTableCapacity(20));
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(2u, dropped_entry_count());
EXPECT_THAT(FindHeaderField("foo", "bar"), FieldsAre(kNoMatch, _, _));
EXPECT_THAT(FindHeaderField("baz", "qux"), FieldsAre(kNoMatch, _, _));
}
TEST_F(QpackEncoderHeaderTableTest, EvictOldestOfIdentical) {
EXPECT_TRUE(SetDynamicTableCapacity(80));
InsertEntry("foo", "bar");
InsertEntry("foo", "bar");
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(0u, dropped_entry_count());
EXPECT_THAT(FindHeaderField("foo", "bar"),
FieldsAre(kNameAndValue, kDynamicEntry, 1u));
InsertEntry("baz", "qux");
EXPECT_EQ(3u, inserted_entry_count());
EXPECT_EQ(1u, dropped_entry_count());
EXPECT_THAT(FindHeaderField("foo", "bar"),
FieldsAre(kNameAndValue, kDynamicEntry, 1u));
EXPECT_THAT(FindHeaderField("baz", "qux"),
FieldsAre(kNameAndValue, kDynamicEntry, 2u));
}
TEST_F(QpackEncoderHeaderTableTest, EvictOldestOfSameName) {
EXPECT_TRUE(SetDynamicTableCapacity(80));
InsertEntry("foo", "bar");
InsertEntry("foo", "baz");
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(0u, dropped_entry_count());
EXPECT_THAT(FindHeaderField("foo", "foo"),
FieldsAre(kName, kDynamicEntry, 1u));
InsertEntry("baz", "qux");
EXPECT_EQ(3u, inserted_entry_count());
EXPECT_EQ(1u, dropped_entry_count());
EXPECT_THAT(FindHeaderField("foo", "foo"),
FieldsAre(kName, kDynamicEntry, 1u));
EXPECT_THAT(FindHeaderField("baz", "qux"),
FieldsAre(kNameAndValue, kDynamicEntry, 2u));
}
TEST_F(QpackEncoderHeaderTableTest, MaxInsertSizeWithoutEvictingGivenEntry) {
const uint64_t dynamic_table_capacity = 100;
EXPECT_TRUE(SetDynamicTableCapacity(dynamic_table_capacity));
EXPECT_EQ(dynamic_table_capacity, MaxInsertSizeWithoutEvictingGivenEntry(0));
const uint64_t entry_size1 = QpackEntry::Size("foo", "bar");
InsertEntry("foo", "bar");
EXPECT_EQ(dynamic_table_capacity - entry_size1,
MaxInsertSizeWithoutEvictingGivenEntry(0));
EXPECT_EQ(dynamic_table_capacity, MaxInsertSizeWithoutEvictingGivenEntry(1));
const uint64_t entry_size2 = QpackEntry::Size("baz", "foobar");
InsertEntry("baz", "foobar");
EXPECT_EQ(dynamic_table_capacity, MaxInsertSizeWithoutEvictingGivenEntry(2));
EXPECT_EQ(dynamic_table_capacity - entry_size2,
MaxInsertSizeWithoutEvictingGivenEntry(1));
EXPECT_EQ(dynamic_table_capacity - entry_size2 - entry_size1,
MaxInsertSizeWithoutEvictingGivenEntry(0));
const uint64_t entry_size3 = QpackEntry::Size("last", "entry");
InsertEntry("last", "entry");
EXPECT_EQ(1u, dropped_entry_count());
EXPECT_EQ(dynamic_table_capacity, MaxInsertSizeWithoutEvictingGivenEntry(3));
EXPECT_EQ(dynamic_table_capacity - entry_size3,
MaxInsertSizeWithoutEvictingGivenEntry(2));
EXPECT_EQ(dynamic_table_capacity - entry_size3 - entry_size2,
MaxInsertSizeWithoutEvictingGivenEntry(1));
}
TEST_F(QpackEncoderHeaderTableTest, DrainingIndex) {
EXPECT_TRUE(SetDynamicTableCapacity(4 * QpackEntry::Size("foo", "bar")));
EXPECT_EQ(0u, draining_index(0.0));
EXPECT_EQ(0u, draining_index(1.0));
InsertEntry("foo", "bar");
EXPECT_EQ(0u, draining_index(0.0));
EXPECT_EQ(1u, draining_index(1.0));
InsertEntry("foo", "bar");
EXPECT_EQ(0u, draining_index(0.0));
EXPECT_EQ(0u, draining_index(0.5));
EXPECT_EQ(2u, draining_index(1.0));
InsertEntry("foo", "bar");
InsertEntry("foo", "bar");
EXPECT_EQ(0u, draining_index(0.0));
EXPECT_EQ(2u, draining_index(0.5));
EXPECT_EQ(4u, draining_index(1.0));
}
class MockObserver : public QpackDecoderHeaderTable::Observer {
public:
~MockObserver() override = default;
MOCK_METHOD(void, OnInsertCountReachedThreshold, (), (override));
MOCK_METHOD(void, Cancel, (), (override));
};
class QpackDecoderHeaderTableTest
: public QpackHeaderTableTest<QpackDecoderHeaderTable> {
protected:
~QpackDecoderHeaderTableTest() override = default;
void ExpectEntryAtIndex(bool is_static, uint64_t index,
absl::string_view expected_name,
absl::string_view expected_value) const {
const auto* entry = table_.LookupEntry(is_static, index);
ASSERT_TRUE(entry);
EXPECT_EQ(expected_name, entry->name());
EXPECT_EQ(expected_value, entry->value());
}
void ExpectNoEntryAtIndex(bool is_static, uint64_t index) const {
EXPECT_FALSE(table_.LookupEntry(is_static, index));
}
void RegisterObserver(uint64_t required_insert_count,
QpackDecoderHeaderTable::Observer* observer) {
table_.RegisterObserver(required_insert_count, observer);
}
void UnregisterObserver(uint64_t required_insert_count,
QpackDecoderHeaderTable::Observer* observer) {
table_.UnregisterObserver(required_insert_count, observer);
}
};
TEST_F(QpackDecoderHeaderTableTest, LookupStaticEntry) {
ExpectEntryAtIndex(kStaticEntry, 0, ":authority", "");
ExpectEntryAtIndex(kStaticEntry, 1, ":path", "/");
ExpectEntryAtIndex(kStaticEntry, 98, "x-frame-options", "sameorigin");
ASSERT_EQ(99u, QpackStaticTableVector().size());
ExpectNoEntryAtIndex(kStaticEntry, 99);
}
TEST_F(QpackDecoderHeaderTableTest, InsertAndLookupDynamicEntry) {
ExpectNoEntryAtIndex(kDynamicEntry, 0);
ExpectNoEntryAtIndex(kDynamicEntry, 1);
ExpectNoEntryAtIndex(kDynamicEntry, 2);
ExpectNoEntryAtIndex(kDynamicEntry, 3);
InsertEntry("foo", "bar");
ExpectEntryAtIndex(kDynamicEntry, 0, "foo", "bar");
ExpectNoEntryAtIndex(kDynamicEntry, 1);
ExpectNoEntryAtIndex(kDynamicEntry, 2);
ExpectNoEntryAtIndex(kDynamicEntry, 3);
InsertEntry("baz", "bing");
ExpectEntryAtIndex(kDynamicEntry, 0, "foo", "bar");
ExpectEntryAtIndex(kDynamicEntry, 1, "baz", "bing");
ExpectNoEntryAtIndex(kDynamicEntry, 2);
ExpectNoEntryAtIndex(kDynamicEntry, 3);
InsertEntry("baz", "bing");
ExpectEntryAtIndex(kDynamicEntry, 0, "foo", "bar");
ExpectEntryAtIndex(kDynamicEntry, 1, "baz", "bing");
ExpectEntryAtIndex(kDynamicEntry, 2, "baz", "bing");
ExpectNoEntryAtIndex(kDynamicEntry, 3);
}
TEST_F(QpackDecoderHeaderTableTest, EvictByInsertion) {
EXPECT_TRUE(SetDynamicTableCapacity(40));
InsertEntry("foo", "bar");
EXPECT_EQ(1u, inserted_entry_count());
EXPECT_EQ(0u, dropped_entry_count());
ExpectEntryAtIndex(kDynamicEntry, 0u, "foo", "bar");
InsertEntry("baz", "qux");
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(1u, dropped_entry_count());
ExpectNoEntryAtIndex(kDynamicEntry, 0u);
ExpectEntryAtIndex(kDynamicEntry, 1u, "baz", "qux");
}
TEST_F(QpackDecoderHeaderTableTest, EvictByUpdateTableSize) {
ExpectNoEntryAtIndex(kDynamicEntry, 0u);
ExpectNoEntryAtIndex(kDynamicEntry, 1u);
InsertEntry("foo", "bar");
InsertEntry("baz", "qux");
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(0u, dropped_entry_count());
ExpectEntryAtIndex(kDynamicEntry, 0u, "foo", "bar");
ExpectEntryAtIndex(kDynamicEntry, 1u, "baz", "qux");
EXPECT_TRUE(SetDynamicTableCapacity(40));
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(1u, dropped_entry_count());
ExpectNoEntryAtIndex(kDynamicEntry, 0u);
ExpectEntryAtIndex(kDynamicEntry, 1u, "baz", "qux");
EXPECT_TRUE(SetDynamicTableCapacity(20));
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(2u, dropped_entry_count());
ExpectNoEntryAtIndex(kDynamicEntry, 0u);
ExpectNoEntryAtIndex(kDynamicEntry, 1u);
}
TEST_F(QpackDecoderHeaderTableTest, EvictOldestOfIdentical) {
EXPECT_TRUE(SetDynamicTableCapacity(80));
InsertEntry("foo", "bar");
InsertEntry("foo", "bar");
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(0u, dropped_entry_count());
ExpectEntryAtIndex(kDynamicEntry, 0u, "foo", "bar");
ExpectEntryAtIndex(kDynamicEntry, 1u, "foo", "bar");
ExpectNoEntryAtIndex(kDynamicEntry, 2u);
InsertEntry("baz", "qux");
EXPECT_EQ(3u, inserted_entry_count());
EXPECT_EQ(1u, dropped_entry_count());
ExpectNoEntryAtIndex(kDynamicEntry, 0u);
ExpectEntryAtIndex(kDynamicEntry, 1u, "foo", "bar");
ExpectEntryAtIndex(kDynamicEntry, 2u, "baz", "qux");
}
TEST_F(QpackDecoderHeaderTableTest, EvictOldestOfSameName) {
EXPECT_TRUE(SetDynamicTableCapacity(80));
InsertEntry("foo", "bar");
InsertEntry("foo", "baz");
EXPECT_EQ(2u, inserted_entry_count());
EXPECT_EQ(0u, dropped_entry_count());
ExpectEntryAtIndex(kDynamicEntry, 0u, "foo", "bar");
ExpectEntryAtIndex(kDynamicEntry, 1u, "foo", "baz");
ExpectNoEntryAtIndex(kDynamicEntry, 2u);
InsertEntry("baz", "qux");
EXPECT_EQ(3u, inserted_entry_count());
EXPECT_EQ(1u, dropped_entry_count());
ExpectNoEntryAtIndex(kDynamicEntry, 0u);
ExpectEntryAtIndex(kDynamicEntry, 1u, "foo", "baz");
ExpectEntryAtIndex(kDynamicEntry, 2u, "baz", "qux");
}
TEST_F(QpackDecoderHeaderTableTest, RegisterObserver) {
StrictMock<MockObserver> observer1;
RegisterObserver(1, &observer1);
EXPECT_CALL(observer1, OnInsertCountReachedThreshold);
InsertEntry("foo", "bar");
EXPECT_EQ(1u, inserted_entry_count());
Mock::VerifyAndClearExpectations(&observer1);
StrictMock<MockObserver> observer2;
StrictMock<MockObserver> observer3;
RegisterObserver(3, &observer3);
RegisterObserver(2, &observer2);
EXPECT_CALL(observer2, OnInsertCountReachedThreshold);
InsertEntry("foo", "bar");
EXPECT_EQ(2u, inserted_entry_count());
Mock::VerifyAndClearExpectations(&observer3);
EXPECT_CALL(observer3, OnInsertCountReachedThreshold);
InsertEntry("foo", "bar");
EXPECT_EQ(3u, inserted_entry_count());
Mock::VerifyAndClearExpectations(&observer2);
StrictMock<MockObserver> observer4;
StrictMock<MockObserver> observer5;
RegisterObserver(4, &observer4);
RegisterObserver(4, &observer5);
EXPECT_CALL(observer4, OnInsertCountReachedThreshold);
EXPECT_CALL(observer5, OnInsertCountReachedThreshold);
InsertEntry("foo", "bar");
EXPECT_EQ(4u, inserted_entry_count());
Mock::VerifyAndClearExpectations(&observer4);
Mock::VerifyAndClearExpectations(&observer5);
}
TEST_F(QpackDecoderHeaderTableTest, UnregisterObserver) {
StrictMock<MockObserver> observer1;
StrictMock<MockObserver> observer2;
StrictMock<MockObserver> observer3;
StrictMock<MockObserver> observer4;
RegisterObserver(1, &observer1);
RegisterObserver(2, &observer2);
RegisterObserver(2, &observer3);
RegisterObserver(3, &observer4);
UnregisterObserver(2, &observer3);
EXPECT_CALL(observer1, OnInsertCountReachedThreshold);
EXPECT_CALL(observer2, OnInsertCountReachedThreshold);
EXPECT_CALL(observer4, OnInsertCountReachedThreshold);
InsertEntry("foo", "bar");
InsertEntry("foo", "bar");
InsertEntry("foo", "bar");
EXPECT_EQ(3u, inserted_entry_count());
}
TEST_F(QpackDecoderHeaderTableTest, Cancel) {
StrictMock<MockObserver> observer;
auto table = std::make_unique<QpackDecoderHeaderTable>();
table->RegisterObserver(1, &observer);
EXPECT_CALL(observer, Cancel);
table.reset();
}
}
}
} | https://github.com/google/quiche/blob/6fe69b2cf77d5fc175a729bc7a6c322a6388b8b6/quiche/quic/core/qpack/qpack_header_table.cc | https://github.com/google/quiche/blob/6fe69b2cf77d5fc175a729bc7a6c322a6388b8b6/quiche/quic/core/qpack/qpack_header_table_test.cc | 6fe69b2cf77d5fc175a729bc7a6c322a6388b8b6 |
77cd2394-1ec2-4b7a-876d-77461d0d270a | cpp | tensorflow/tensorflow | transpose_test_utils | tensorflow/lite/kernels/transpose_test_utils.h | tensorflow/lite/kernels/transpose_test_utils_test.cc | "#ifndef TENSORFLOW_LITE_KERNELS_TRANSPOSE_TEST_UTILS_H_\n#define TENSORFLOW_LITE_KERNELS_TRANSPOSE_(...TRUNCATED) | "#include \"tensorflow/lite/kernels/transpose_test_utils.h\"\n#include <vector>\n#include <gmock/gmo(...TRUNCATED) | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/tensorflow/lite/kernels/transpose_test_utils.h | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/tensorflow/lite/kernels/transpose_test_utils_test.cc | 4a29233a7b7c1a3a4294e4ccdd1772f9083944ea |
b177da21-0cd6-4142-be0f-c1ea4d838d88 | cpp | google/quiche | oblivious_http_gateway | quiche/oblivious_http/oblivious_http_gateway.cc | quiche/oblivious_http/oblivious_http_gateway_test.cc | "#include \"quiche/oblivious_http/oblivious_http_gateway.h\"\n#include <stdint.h>\n#include <memory>(...TRUNCATED) | "#include \"quiche/oblivious_http/oblivious_http_gateway.h\"\n#include <stdint.h>\n#include <string>(...TRUNCATED) | https://github.com/google/quiche/blob/6fe69b2cf77d5fc175a729bc7a6c322a6388b8b6/quiche/oblivious_http/oblivious_http_gateway.cc | https://github.com/google/quiche/blob/6fe69b2cf77d5fc175a729bc7a6c322a6388b8b6/quiche/oblivious_http/oblivious_http_gateway_test.cc | 6fe69b2cf77d5fc175a729bc7a6c322a6388b8b6 |
05ba9773-8dd8-4974-a475-170f6c840a77 | cpp | tensorflow/tensorflow | random_op | tensorflow/core/kernels/random_op.cc | tensorflow/core/kernels/random_op_test.cc | "#define EIGEN_USE_THREADS\n#include <algorithm>\n#include <cmath>\n#include <memory>\n#include \"te(...TRUNCATED) | "#include <random>\n#include \"tensorflow/core/common_runtime/kernel_benchmark_testlib.h\"\n#include(...TRUNCATED) | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/tensorflow/core/kernels/random_op.cc | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/tensorflow/core/kernels/random_op_test.cc | 4a29233a7b7c1a3a4294e4ccdd1772f9083944ea |
f92f7a68-f778-4514-9db2-42387ef2abfa | cpp | google/tensorstore | json_gtest | tensorstore/internal/json_gtest.cc | tensorstore/internal/json_gtest_test.cc | "#include \"tensorstore/internal/json_gtest.h\"\n#include <ostream>\n#include <string>\n#include <ut(...TRUNCATED) | "#include \"tensorstore/internal/json_gtest.h\"\n#include <sstream>\n#include <string>\n#include <gm(...TRUNCATED) | https://github.com/google/tensorstore/blob/4f887a6430414cd6088e1743555015b10f116d50/tensorstore/internal/json_gtest.cc | https://github.com/google/tensorstore/blob/4f887a6430414cd6088e1743555015b10f116d50/tensorstore/internal/json_gtest_test.cc | 4f887a6430414cd6088e1743555015b10f116d50 |
94696138-88ad-406c-84d3-0739ede2539f | cpp | tensorflow/tensorflow | full_type_util | tensorflow/core/framework/full_type_util.cc | tensorflow/core/framework/full_type_util_test.cc | "#include \"tensorflow/core/framework/full_type_util.h\"\n#include <algorithm>\n#include <string>\n#(...TRUNCATED) | "#include \"tensorflow/core/framework/attr_value.pb.h\"\n#include \"tensorflow/core/framework/full_t(...TRUNCATED) | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/tensorflow/core/framework/full_type_util.cc | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/tensorflow/core/framework/full_type_util_test.cc | 4a29233a7b7c1a3a4294e4ccdd1772f9083944ea |
896b5f77-9df8-45ee-8777-37ac3e99637f | cpp | google/libaddressinput | address_normalizer | cpp/src/address_normalizer.cc | cpp/test/address_normalizer_test.cc | "#include <libaddressinput/address_normalizer.h>\n#include <libaddressinput/address_data.h>\n#includ(...TRUNCATED) | "#include <libaddressinput/address_normalizer.h>\n#include <libaddressinput/address_data.h>\n#includ(...TRUNCATED) | https://github.com/google/libaddressinput/blob/2610f7b1043d6784ada41392fc9392d1ea09ea07/cpp/src/address_normalizer.cc | https://github.com/google/libaddressinput/blob/2610f7b1043d6784ada41392fc9392d1ea09ea07/cpp/test/address_normalizer_test.cc | 2610f7b1043d6784ada41392fc9392d1ea09ea07 |
5e5b458c-749f-4599-ab52-44f385a4c5f4 | cpp | tensorflow/tensorflow | stream_executor_util | third_party/xla/xla/service/gpu/stream_executor_util.cc | third_party/xla/xla/service/gpu/stream_executor_util_test.cc | "#include \"xla/service/gpu/stream_executor_util.h\"\n#include <cstdint>\n#include <iterator>\n#incl(...TRUNCATED) | "#include \"xla/service/gpu/stream_executor_util.h\"\n#include <cstdint>\n#include <vector>\n#includ(...TRUNCATED) | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/third_party/xla/xla/service/gpu/stream_executor_util.cc | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/third_party/xla/xla/service/gpu/stream_executor_util_test.cc | 4a29233a7b7c1a3a4294e4ccdd1772f9083944ea |
dde88d8c-a50e-4c90-9f5c-0a007cee16b9 | cpp | tensorflow/tensorflow | colocate_predecessor_trees_pass | tensorflow/core/common_runtime/colocate_predecessor_trees_pass.cc | tensorflow/core/common_runtime/colocate_predecessor_trees_pass_test.cc | "#include \"tensorflow/core/common_runtime/colocate_predecessor_trees_pass.h\"\n#include <optional>\(...TRUNCATED) | "#include \"tensorflow/core/common_runtime/colocate_predecessor_trees_pass.h\"\n#include <memory>\n#(...TRUNCATED) | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/tensorflow/core/common_runtime/colocate_predecessor_trees_pass.cc | https://github.com/tensorflow/tensorflow/blob/4a29233a7b7c1a3a4294e4ccdd1772f9083944ea/tensorflow/core/common_runtime/colocate_predecessor_trees_pass_test.cc | 4a29233a7b7c1a3a4294e4ccdd1772f9083944ea |
4f659819-6eca-4f9c-a250-a5fa655698cb | cpp | abseil/abseil-cpp | layout | absl/container/internal/layout.h | absl/container/internal/layout_test.cc | "#ifndef ABSL_CONTAINER_INTERNAL_LAYOUT_H_\n#define ABSL_CONTAINER_INTERNAL_LAYOUT_H_\n#include <ass(...TRUNCATED) | "#include \"absl/container/internal/layout.h\"\n#include <stddef.h>\n#include <cstdint>\n#include <c(...TRUNCATED) | https://github.com/abseil/abseil-cpp/blob/03b8d6ea3dc6a0b8c6bcf42503c2053754dab2e4/absl/container/internal/layout.h | https://github.com/abseil/abseil-cpp/blob/03b8d6ea3dc6a0b8c6bcf42503c2053754dab2e4/absl/container/internal/layout_test.cc | 03b8d6ea3dc6a0b8c6bcf42503c2053754dab2e4 |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
Use the Edit dataset card button to edit it.
- Downloads last month
- 34