Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(956)

Unified Diff: net/spdy/hpack/hpack_decoder3_test.cc

Issue 2801603003: Add SpdyString alias for std::string in net/spdy. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/hpack/hpack_decoder.cc ('k') | net/spdy/hpack/hpack_decoder_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/hpack/hpack_decoder3_test.cc
diff --git a/net/spdy/hpack/hpack_decoder3_test.cc b/net/spdy/hpack/hpack_decoder3_test.cc
index 85752aa2c03d71b3d7082475a4557a9541b76db2..73279aa66d7339673ebe21bfab82808ebd44519f 100644
--- a/net/spdy/hpack/hpack_decoder3_test.cc
+++ b/net/spdy/hpack/hpack_decoder3_test.cc
@@ -8,7 +8,6 @@
#include <stdint.h>
-#include <string>
#include <tuple>
#include <utility>
#include <vector>
@@ -23,11 +22,11 @@
#include "net/spdy/hpack/hpack_encoder.h"
#include "net/spdy/hpack/hpack_huffman_table.h"
#include "net/spdy/hpack/hpack_output_stream.h"
+#include "net/spdy/platform/api/spdy_string.h"
#include "net/spdy/spdy_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-using std::string;
using ::testing::ElementsAre;
using ::testing::Pair;
@@ -174,8 +173,8 @@ class HpackDecoder3Test
void expectEntry(size_t index,
size_t size,
- const string& name,
- const string& value) {
+ const SpdyString& name,
+ const SpdyString& value) {
const HpackStringPair* entry = decoder_peer_.GetTableEntry(index);
EXPECT_EQ(name, entry->name) << "index " << index;
EXPECT_EQ(value, entry->value);
@@ -183,7 +182,7 @@ class HpackDecoder3Test
}
SpdyHeaderBlock MakeHeaderBlock(
- const std::vector<std::pair<string, string>>& headers) {
+ const std::vector<std::pair<SpdyString, SpdyString>>& headers) {
SpdyHeaderBlock result;
for (const auto& kv : headers) {
result.AppendValueOrAddHeader(kv.first, kv.second);
@@ -214,12 +213,12 @@ TEST_P(HpackDecoder3Test, AddHeaderDataWithHandleControlFrameHeadersData) {
// limit is rejected.
HandleControlFrameHeadersStart();
const size_t kMaxBufferSizeBytes = 50;
- const string a_value = string(49, 'x');
+ const SpdyString a_value = SpdyString(49, 'x');
decoder_.set_max_decode_buffer_size_bytes(kMaxBufferSizeBytes);
HpackBlockBuilder hbb;
hbb.AppendLiteralNameAndValue(HpackEntryType::kNeverIndexedLiteralHeader,
false, "a", false, a_value);
- const string& s = hbb.buffer();
+ const SpdyString& s = hbb.buffer();
EXPECT_GT(s.size(), kMaxBufferSizeBytes);
// Any one in input buffer must not exceed kMaxBufferSizeBytes.
@@ -234,8 +233,8 @@ TEST_P(HpackDecoder3Test, AddHeaderDataWithHandleControlFrameHeadersData) {
TEST_P(HpackDecoder3Test, NameTooLong) {
// Verify that a name longer than the allowed size generates an error.
const size_t kMaxBufferSizeBytes = 50;
- const string name = string(2 * kMaxBufferSizeBytes, 'x');
- const string value = "abc";
+ const SpdyString name = SpdyString(2 * kMaxBufferSizeBytes, 'x');
+ const SpdyString value = "abc";
decoder_.set_max_decode_buffer_size_bytes(kMaxBufferSizeBytes);
@@ -244,7 +243,7 @@ TEST_P(HpackDecoder3Test, NameTooLong) {
false, name, false, value);
const size_t fragment_size = (3 * kMaxBufferSizeBytes) / 2;
- const string fragment = hbb.buffer().substr(0, fragment_size);
+ const SpdyString fragment = hbb.buffer().substr(0, fragment_size);
HandleControlFrameHeadersStart();
EXPECT_FALSE(HandleControlFrameHeadersData(fragment));
@@ -253,8 +252,8 @@ TEST_P(HpackDecoder3Test, NameTooLong) {
TEST_P(HpackDecoder3Test, HeaderTooLongToBuffer) {
// Verify that a header longer than the allowed size generates an error if
// it isn't all in one input buffer.
- const string name = "some-key";
- const string value = "some-value";
+ const SpdyString name = "some-key";
+ const SpdyString value = "some-value";
const size_t kMaxBufferSizeBytes = name.size() + value.size() - 2;
decoder_.set_max_decode_buffer_size_bytes(kMaxBufferSizeBytes);
@@ -262,7 +261,7 @@ TEST_P(HpackDecoder3Test, HeaderTooLongToBuffer) {
hbb.AppendLiteralNameAndValue(HpackEntryType::kNeverIndexedLiteralHeader,
false, name, false, value);
const size_t fragment_size = hbb.size() - 1;
- const string fragment = hbb.buffer().substr(0, fragment_size);
+ const SpdyString fragment = hbb.buffer().substr(0, fragment_size);
HandleControlFrameHeadersStart();
EXPECT_FALSE(HandleControlFrameHeadersData(fragment));
@@ -274,7 +273,7 @@ TEST_P(HpackDecoder3Test, DecodeWithIncompleteData) {
// No need to wait for more data.
EXPECT_TRUE(HandleControlFrameHeadersData("\x82\x85\x82"));
- std::vector<std::pair<string, string>> expected_headers = {
+ std::vector<std::pair<SpdyString, SpdyString>> expected_headers = {
{":method", "GET"}, {":path", "/index.html"}, {":method", "GET"}};
SpdyHeaderBlock expected_block1 = MakeHeaderBlock(expected_headers);
@@ -315,7 +314,7 @@ TEST_P(HpackDecoder3Test, HandleHeaderRepresentation) {
// Already-delimited headers are passed through.
decoder_peer_.HandleHeaderRepresentation("passed-through",
- string("foo\0baz", 7));
+ SpdyString("foo\0baz", 7));
// Other headers are joined on \0. Case matters.
decoder_peer_.HandleHeaderRepresentation("joined", "not joined");
@@ -402,7 +401,7 @@ TEST_P(HpackDecoder3Test, InvalidIndexedHeader) {
TEST_P(HpackDecoder3Test, ContextUpdateMaximumSize) {
EXPECT_EQ(kDefaultHeaderTableSizeSetting,
decoder_peer_.header_table_size_limit());
- string input;
+ SpdyString input;
{
// Maximum-size update with size 126. Succeeds.
HpackOutputStream output_stream;
@@ -439,7 +438,7 @@ TEST_P(HpackDecoder3Test, ContextUpdateMaximumSize) {
// Two HeaderTableSizeUpdates may appear at the beginning of the block
TEST_P(HpackDecoder3Test, TwoTableSizeUpdates) {
- string input;
+ SpdyString input;
{
// Should accept two table size updates, update to second one
HpackOutputStream output_stream;
@@ -456,7 +455,7 @@ TEST_P(HpackDecoder3Test, TwoTableSizeUpdates) {
// Three HeaderTableSizeUpdates should result in an error
TEST_P(HpackDecoder3Test, ThreeTableSizeUpdatesError) {
- string input;
+ SpdyString input;
{
// Should reject three table size updates, update to second one
HpackOutputStream output_stream;
@@ -477,7 +476,7 @@ TEST_P(HpackDecoder3Test, ThreeTableSizeUpdatesError) {
// HeaderTableSizeUpdates may only appear at the beginning of the block
// Any other updates should result in an error
TEST_P(HpackDecoder3Test, TableSizeUpdateSecondError) {
- string input;
+ SpdyString input;
{
// Should reject a table size update appearing after a different entry
// The table size should remain as the default
@@ -497,7 +496,7 @@ TEST_P(HpackDecoder3Test, TableSizeUpdateSecondError) {
// HeaderTableSizeUpdates may only appear at the beginning of the block
// Any other updates should result in an error
TEST_P(HpackDecoder3Test, TableSizeUpdateFirstThirdError) {
- string input;
+ SpdyString input;
{
// Should reject the second table size update
// if a different entry appears after the first update
@@ -588,7 +587,7 @@ TEST_P(HpackDecoder3Test, TruncatedHuffmanLiteral) {
// | www.example.com
// | -> :authority: www.example.com
- string first = a2b_hex("418cf1e3c2e5f23a6ba0ab90f4ff");
+ SpdyString first = a2b_hex("418cf1e3c2e5f23a6ba0ab90f4ff");
EXPECT_TRUE(DecodeHeaderBlock(first));
first = a2b_hex("418cf1e3c2e5f23a6ba0ab90f4");
EXPECT_FALSE(DecodeHeaderBlock(first));
@@ -608,7 +607,7 @@ TEST_P(HpackDecoder3Test, HuffmanEOSError) {
// | www.example.com
// | -> :authority: www.example.com
- string first = a2b_hex("418cf1e3c2e5f23a6ba0ab90f4ff");
+ SpdyString first = a2b_hex("418cf1e3c2e5f23a6ba0ab90f4ff");
EXPECT_TRUE(DecodeHeaderBlock(first));
first = a2b_hex("418df1e3c2e5f23a6ba0ab90f4ffff");
EXPECT_FALSE(DecodeHeaderBlock(first));
@@ -625,7 +624,7 @@ TEST_P(HpackDecoder3Test, BasicC31) {
expected_header_set[":path"] = "/";
expected_header_set[":authority"] = "www.example.com";
- string encoded_header_set;
+ SpdyString encoded_header_set;
EXPECT_TRUE(
encoder.EncodeHeaderSet(expected_header_set, &encoded_header_set));
@@ -656,7 +655,7 @@ TEST_P(HpackDecoder3Test, SectionC4RequestHuffmanExamples) {
// | Decoded:
// | www.example.com
// | -> :authority: www.example.com
- string first = a2b_hex("828684418cf1e3c2e5f23a6ba0ab90f4ff");
+ SpdyString first = a2b_hex("828684418cf1e3c2e5f23a6ba0ab90f4ff");
const SpdyHeaderBlock& first_header_set = DecodeBlockExpectingSuccess(first);
EXPECT_THAT(first_header_set,
@@ -693,7 +692,7 @@ TEST_P(HpackDecoder3Test, SectionC4RequestHuffmanExamples) {
// | no-cache
// | -> cache-control: no-cache
- string second = a2b_hex("828684be5886a8eb10649cbf");
+ SpdyString second = a2b_hex("828684be5886a8eb10649cbf");
const SpdyHeaderBlock& second_header_set =
DecodeBlockExpectingSuccess(second);
@@ -735,7 +734,8 @@ TEST_P(HpackDecoder3Test, SectionC4RequestHuffmanExamples) {
// | Decoded:
// | custom-value
// | -> custom-key: custom-value
- string third = a2b_hex("828785bf408825a849e95ba97d7f8925a849e95bb8e8b4bf");
+ SpdyString third =
+ a2b_hex("828785bf408825a849e95ba97d7f8925a849e95bb8e8b4bf");
const SpdyHeaderBlock& third_header_set = DecodeBlockExpectingSuccess(third);
EXPECT_THAT(
@@ -804,7 +804,7 @@ TEST_P(HpackDecoder3Test, SectionC6ResponseHuffmanExamples) {
// | -> location: https://www.e
// | xample.com
- string first = a2b_hex(
+ SpdyString first = a2b_hex(
"488264025885aec3771a4b6196d07abe"
"941054d444a8200595040b8166e082a6"
"2d1bff6e919d29ad171863c78f0b97c8"
@@ -847,7 +847,7 @@ TEST_P(HpackDecoder3Test, SectionC6ResponseHuffmanExamples) {
// | idx = 63
// | -> location:
// | https://www.example.com
- string second = a2b_hex("4883640effc1c0bf");
+ SpdyString second = a2b_hex("4883640effc1c0bf");
const SpdyHeaderBlock& second_header_set =
DecodeBlockExpectingSuccess(second);
@@ -919,7 +919,7 @@ TEST_P(HpackDecoder3Test, SectionC6ResponseHuffmanExamples) {
// | -> set-cookie: foo=ASDJKHQ
// | KBZXOQWEOPIUAXQWEOIU;
// | max-age=3600; version=1
- string third = a2b_hex(
+ SpdyString third = a2b_hex(
"88c16196d07abe941054d444a8200595"
"040b8166e084a62d1bffc05a839bd9ab"
"77ad94e7821dd7f2e6c7b335dfdfcd5b"
@@ -1000,7 +1000,7 @@ TEST_P(HpackDecoder3Test, ReuseNameOfEvictedEntry) {
// SpdyHeaderBlock stores these 6 strings as '\0' separated values.
// Make sure that is what happened.
- string joined_values = expected_header_set[name].as_string();
+ SpdyString joined_values = expected_header_set[name].as_string();
EXPECT_EQ(joined_values.size(),
2 * value1.size() + 2 * value2.size() + 2 * value3.size() + 5);
« no previous file with comments | « net/spdy/hpack/hpack_decoder.cc ('k') | net/spdy/hpack/hpack_decoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698