QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // Copyright (c) 2018 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/third_party/quiche/src/quic/platform/api/quic_containers.h" |
| 6 | |
| 7 | #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" |
| 8 | |
| 9 | using ::testing::ElementsAre; |
| 10 | |
| 11 | namespace quic { |
| 12 | namespace test { |
| 13 | namespace { |
| 14 | |
| 15 | TEST(QuicInlinedVectorTest, Swap) { |
| 16 | { |
| 17 | // Inline to inline. |
| 18 | QuicInlinedVector<int, 2> self({1, 2}); |
| 19 | QuicInlinedVector<int, 2> other({3}); |
| 20 | |
| 21 | self.swap(other); |
| 22 | |
| 23 | EXPECT_THAT(self, ElementsAre(3)); |
| 24 | EXPECT_THAT(other, ElementsAre(1, 2)); |
| 25 | } |
| 26 | |
| 27 | { |
| 28 | // Inline to out-of-line. |
| 29 | QuicInlinedVector<int, 2> self({1, 2}); |
| 30 | QuicInlinedVector<int, 2> other({3, 4, 5, 6}); |
| 31 | |
| 32 | self.swap(other); |
| 33 | |
| 34 | EXPECT_THAT(self, ElementsAre(3, 4, 5, 6)); |
| 35 | EXPECT_THAT(other, ElementsAre(1, 2)); |
| 36 | } |
| 37 | |
| 38 | { |
| 39 | // Out-of-line to inline. |
| 40 | QuicInlinedVector<int, 2> self({1, 2, 3}); |
| 41 | QuicInlinedVector<int, 2> other({4, 5}); |
| 42 | |
| 43 | self.swap(other); |
| 44 | |
| 45 | EXPECT_THAT(self, ElementsAre(4, 5)); |
| 46 | EXPECT_THAT(other, ElementsAre(1, 2, 3)); |
| 47 | } |
| 48 | |
| 49 | { |
| 50 | // Out-of-line to Out-of-line. |
| 51 | QuicInlinedVector<int, 2> self({1, 2, 3}); |
| 52 | QuicInlinedVector<int, 2> other({4, 5, 6, 7}); |
| 53 | |
| 54 | self.swap(other); |
| 55 | |
| 56 | EXPECT_THAT(self, ElementsAre(4, 5, 6, 7)); |
| 57 | EXPECT_THAT(other, ElementsAre(1, 2, 3)); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | } // namespace |
| 62 | } // namespace test |
| 63 | } // namespace quic |