summaryrefslogtreecommitdiff
path: root/test/gtest/arena.cpp
blob: 7453ea9f6155406c3dd68928a9dee0d484a2666d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "mixed_arena.h"
#include "gtest/gtest.h"

using ArenaTest = ::testing::Test;

TEST_F(ArenaTest, Swap) {
  MixedArena arena;

  ArenaVector<int> a(arena);
  a.push_back(10);
  a.push_back(20);

  ArenaVector<int> b(arena);

  EXPECT_EQ(a.size(), 2U);
  EXPECT_EQ(b.size(), 0U);

  a.swap(b);

  EXPECT_EQ(a.size(), 0U);
  EXPECT_EQ(b.size(), 2U);

  a.swap(b);

  EXPECT_EQ(a.size(), 2U);
  EXPECT_EQ(b.size(), 0U);

  // Now reverse a and b. The swap should be the same.

  b.swap(a);

  EXPECT_EQ(a.size(), 0U);
  EXPECT_EQ(b.size(), 2U);

  b.swap(a);

  EXPECT_EQ(a.size(), 2U);
  EXPECT_EQ(b.size(), 0U);
}