OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/quic/quic_header_list.h" |
| 6 |
| 7 #include "net/test/gtest_util.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 |
| 10 namespace net { |
| 11 |
| 12 class QuicHeaderListTest : public ::testing::Test {}; |
| 13 |
| 14 // This test verifies that QuicHeaderList accumulates header pairs in order. |
| 15 TEST(QuicHeaderListTest, OnHeader) { |
| 16 QuicHeaderList headers; |
| 17 headers.OnHeader("foo", "bar"); |
| 18 headers.OnHeader("april", "fools"); |
| 19 headers.OnHeader("beep", ""); |
| 20 |
| 21 std::string accumulator; |
| 22 for (const auto& p : headers) { |
| 23 accumulator.append("(" + p.first + ", " + p.second + ") "); |
| 24 } |
| 25 EXPECT_EQ("(foo, bar) (april, fools) (beep, ) ", accumulator); |
| 26 } |
| 27 |
| 28 // This test verifies that QuicHeaderList is copyable and assignable. |
| 29 TEST(QuicHeaderListTest, IsCopyableAndAssignable) { |
| 30 QuicHeaderList headers; |
| 31 headers.OnHeader("foo", "bar"); |
| 32 headers.OnHeader("april", "fools"); |
| 33 headers.OnHeader("beep", ""); |
| 34 |
| 35 QuicHeaderList headers2(headers); |
| 36 QuicHeaderList headers3 = headers; |
| 37 |
| 38 std::string accumulator; |
| 39 for (const auto& p : headers2) { |
| 40 accumulator.append("(" + p.first + ", " + p.second + ") "); |
| 41 } |
| 42 EXPECT_EQ("(foo, bar) (april, fools) (beep, ) ", accumulator); |
| 43 |
| 44 accumulator.clear(); |
| 45 for (const auto& p : headers3) { |
| 46 accumulator.append("(" + p.first + ", " + p.second + ") "); |
| 47 } |
| 48 EXPECT_EQ("(foo, bar) (april, fools) (beep, ) ", accumulator); |
| 49 } |
| 50 |
| 51 } // namespace net |
OLD | NEW |