blob: 185f536271db2f94233a79878e178deb2020c059 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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
10namespace quic {
11namespace test {
12namespace {
13
14class 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
29TEST_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
38TEST_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