diff options
Diffstat (limited to 'test/gtest/arena.cpp')
-rw-r--r-- | test/gtest/arena.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/gtest/arena.cpp b/test/gtest/arena.cpp new file mode 100644 index 000000000..7453ea9f6 --- /dev/null +++ b/test/gtest/arena.cpp @@ -0,0 +1,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); +} |