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

Side by Side Diff: net/spdy/http2_compressor_unittest.cc

Issue 22074002: DO NOT COMMIT: Implement HPACK (draft 03) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update for httpbis-draft-06 / hpack-draft-03 Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/http2_compressor.cc ('k') | net/spdy/http2_decompressor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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/http2_compressor.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace net {
9 namespace {
10
11 class Http2CompressorTest : public ::testing::Test {
12 };
13
14 TEST_F(Http2CompressorTest, Simple) {
15 Http2Compressor compressor;
16 SpdyNameValueBlock name_value_block;
17 name_value_block["name1"] = "value1";
18 name_value_block["name2"] = "value2";
19 name_value_block["name3"] = "value3";
20
21 std::string expected_encoded;
22 expected_encoded.append(1, 0x60);
23 expected_encoded.append(1, 0x05);
24 expected_encoded.append("name1");
25 expected_encoded.append(1, 0x06);
26 expected_encoded.append("value1");
27 expected_encoded.append(1, 0x60);
28 expected_encoded.append(1, 0x05);
29 expected_encoded.append("name2");
30 expected_encoded.append(1, 0x06);
31 expected_encoded.append("value2");
32 expected_encoded.append(1, 0x60);
33 expected_encoded.append(1, 0x05);
34 expected_encoded.append("name3");
35 expected_encoded.append(1, 0x06);
36 expected_encoded.append("value3");
37
38 std::string encoded = compressor.EncodeNameValueBlock(name_value_block);
39 EXPECT_EQ(expected_encoded, encoded);
40 }
41
42 TEST_F(Http2CompressorTest, Long) {
43 Http2Compressor compressor;
44 SpdyNameValueBlock name_value_block;
45 std::string name(1000, 'n');
46 std::string value(10000, 'v');
47 name_value_block[name] = value;
48
49 std::string expected_encoded;
50 expected_encoded.append(1, 0x60);
51 expected_encoded.append(1, 0x80 | 104);
52 expected_encoded.append(1, 7);
53 expected_encoded.append(name);
54 expected_encoded.append(1, 0x80 | 16);
55 expected_encoded.append(1, 78);
56 expected_encoded.append(value);
57
58 std::string encoded = compressor.EncodeNameValueBlock(name_value_block);
59 EXPECT_EQ(expected_encoded, encoded);
60 }
61
62 } // namespace
63 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/http2_compressor.cc ('k') | net/spdy/http2_decompressor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698