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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/http2_compressor.cc ('k') | net/spdy/http2_decompressor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/http2_compressor_unittest.cc
diff --git a/net/spdy/http2_compressor_unittest.cc b/net/spdy/http2_compressor_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a3b3627ab0c8c2911096ef4f2d8d2812af216b89
--- /dev/null
+++ b/net/spdy/http2_compressor_unittest.cc
@@ -0,0 +1,63 @@
+// Copyright 2013 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 "net/spdy/http2_compressor.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace {
+
+class Http2CompressorTest : public ::testing::Test {
+};
+
+TEST_F(Http2CompressorTest, Simple) {
+ Http2Compressor compressor;
+ SpdyNameValueBlock name_value_block;
+ name_value_block["name1"] = "value1";
+ name_value_block["name2"] = "value2";
+ name_value_block["name3"] = "value3";
+
+ std::string expected_encoded;
+ expected_encoded.append(1, 0x60);
+ expected_encoded.append(1, 0x05);
+ expected_encoded.append("name1");
+ expected_encoded.append(1, 0x06);
+ expected_encoded.append("value1");
+ expected_encoded.append(1, 0x60);
+ expected_encoded.append(1, 0x05);
+ expected_encoded.append("name2");
+ expected_encoded.append(1, 0x06);
+ expected_encoded.append("value2");
+ expected_encoded.append(1, 0x60);
+ expected_encoded.append(1, 0x05);
+ expected_encoded.append("name3");
+ expected_encoded.append(1, 0x06);
+ expected_encoded.append("value3");
+
+ std::string encoded = compressor.EncodeNameValueBlock(name_value_block);
+ EXPECT_EQ(expected_encoded, encoded);
+}
+
+TEST_F(Http2CompressorTest, Long) {
+ Http2Compressor compressor;
+ SpdyNameValueBlock name_value_block;
+ std::string name(1000, 'n');
+ std::string value(10000, 'v');
+ name_value_block[name] = value;
+
+ std::string expected_encoded;
+ expected_encoded.append(1, 0x60);
+ expected_encoded.append(1, 0x80 | 104);
+ expected_encoded.append(1, 7);
+ expected_encoded.append(name);
+ expected_encoded.append(1, 0x80 | 16);
+ expected_encoded.append(1, 78);
+ expected_encoded.append(value);
+
+ std::string encoded = compressor.EncodeNameValueBlock(name_value_block);
+ EXPECT_EQ(expected_encoded, encoded);
+}
+
+} // namespace
+} // namespace net
« 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