QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame^] | 1 | // Copyright 2017 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_mem_slice.h" |
| 6 | |
| 7 | #include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" |
| 8 | #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" |
| 9 | |
| 10 | namespace quic { |
| 11 | namespace test { |
| 12 | namespace { |
| 13 | |
| 14 | class QuicMemSliceTest : public QuicTest { |
| 15 | public: |
| 16 | QuicMemSliceTest() { |
| 17 | size_t length = 1024; |
| 18 | slice_ = QuicMemSlice(&allocator_, length); |
| 19 | orig_data_ = slice_.data(); |
| 20 | orig_length_ = slice_.length(); |
| 21 | } |
| 22 | |
| 23 | SimpleBufferAllocator allocator_; |
| 24 | QuicMemSlice slice_; |
| 25 | const char* orig_data_; |
| 26 | size_t orig_length_; |
| 27 | }; |
| 28 | |
| 29 | TEST_F(QuicMemSliceTest, MoveConstruct) { |
| 30 | QuicMemSlice moved(std::move(slice_)); |
| 31 | EXPECT_EQ(moved.data(), orig_data_); |
| 32 | EXPECT_EQ(moved.length(), orig_length_); |
| 33 | EXPECT_EQ(nullptr, slice_.data()); |
| 34 | EXPECT_EQ(0u, slice_.length()); |
| 35 | EXPECT_TRUE(slice_.empty()); |
| 36 | } |
| 37 | |
| 38 | TEST_F(QuicMemSliceTest, MoveAssign) { |
| 39 | QuicMemSlice moved; |
| 40 | moved = std::move(slice_); |
| 41 | EXPECT_EQ(moved.data(), orig_data_); |
| 42 | EXPECT_EQ(moved.length(), orig_length_); |
| 43 | EXPECT_EQ(nullptr, slice_.data()); |
| 44 | EXPECT_EQ(0u, slice_.length()); |
| 45 | EXPECT_TRUE(slice_.empty()); |
| 46 | } |
| 47 | |
| 48 | } // namespace |
| 49 | } // namespace test |
| 50 | } // namespace quic |