OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_header_list.h" | 5 #include "net/quic/quic_header_list.h" |
6 | 6 |
7 #include "net/test/gtest_util.h" | 7 #include "net/test/gtest_util.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 | 11 |
12 // This test verifies that QuicHeaderList accumulates header pairs in order. | 12 // This test verifies that QuicHeaderList accumulates header pairs in order. |
13 TEST(QuicHeaderListTest, OnHeader) { | 13 TEST(QuicHeaderListTest, OnHeader) { |
14 QuicHeaderList headers; | 14 QuicHeaderList headers; |
15 headers.OnHeader("foo", "bar"); | 15 headers.OnHeader("foo", "bar"); |
16 headers.OnHeader("april", "fools"); | 16 headers.OnHeader("april", "fools"); |
17 headers.OnHeader("beep", ""); | 17 headers.OnHeader("beep", ""); |
18 | 18 |
19 std::string accumulator; | 19 EXPECT_EQ("{ foo=bar, april=fools, beep=, }", headers.DebugString()); |
20 for (const auto& p : headers) { | |
21 accumulator.append("(" + p.first + ", " + p.second + ") "); | |
22 } | |
23 EXPECT_EQ("(foo, bar) (april, fools) (beep, ) ", accumulator); | |
24 } | 20 } |
25 | 21 |
26 // This test verifies that QuicHeaderList is copyable and assignable. | 22 // This test verifies that QuicHeaderList is copyable and assignable. |
27 TEST(QuicHeaderListTest, IsCopyableAndAssignable) { | 23 TEST(QuicHeaderListTest, IsCopyableAndAssignable) { |
28 QuicHeaderList headers; | 24 QuicHeaderList headers; |
29 headers.OnHeader("foo", "bar"); | 25 headers.OnHeader("foo", "bar"); |
30 headers.OnHeader("april", "fools"); | 26 headers.OnHeader("april", "fools"); |
31 headers.OnHeader("beep", ""); | 27 headers.OnHeader("beep", ""); |
32 | 28 |
33 QuicHeaderList headers2(headers); | 29 QuicHeaderList headers2(headers); |
34 QuicHeaderList headers3 = headers; | 30 QuicHeaderList headers3 = headers; |
35 | 31 |
36 std::string accumulator; | 32 EXPECT_EQ("{ foo=bar, april=fools, beep=, }", headers2.DebugString()); |
37 for (const auto& p : headers2) { | 33 EXPECT_EQ("{ foo=bar, april=fools, beep=, }", headers3.DebugString()); |
38 accumulator.append("(" + p.first + ", " + p.second + ") "); | |
39 } | |
40 EXPECT_EQ("(foo, bar) (april, fools) (beep, ) ", accumulator); | |
41 | |
42 accumulator.clear(); | |
43 for (const auto& p : headers3) { | |
44 accumulator.append("(" + p.first + ", " + p.second + ") "); | |
45 } | |
46 EXPECT_EQ("(foo, bar) (april, fools) (beep, ) ", accumulator); | |
47 } | 34 } |
48 | 35 |
49 } // namespace net | 36 } // namespace net |
OLD | NEW |