#include #include #include "gtest/gtest.h" #include "libpmr/small_storage.h" TEST(small_storage, holder_construct) { pmr::holder_null(); pmr::holder(); pmr::holder(); pmr::holder(); SUCCEED(); } TEST(small_storage, holder_copy_move_construct) { EXPECT_FALSE(std::is_copy_constructible::value); EXPECT_FALSE((std::is_copy_constructible>::value)); EXPECT_FALSE((std::is_copy_constructible>::value)); EXPECT_FALSE((std::is_copy_constructible>::value)); EXPECT_FALSE(std::is_copy_assignable::value); EXPECT_FALSE((std::is_copy_assignable>::value)); EXPECT_FALSE((std::is_copy_assignable>::value)); EXPECT_FALSE((std::is_copy_assignable>::value)); EXPECT_FALSE(std::is_move_constructible::value); EXPECT_FALSE((std::is_move_constructible>::value)); EXPECT_FALSE((std::is_move_constructible>::value)); EXPECT_FALSE((std::is_move_constructible>::value)); EXPECT_FALSE(std::is_move_assignable::value); EXPECT_FALSE((std::is_move_assignable>::value)); EXPECT_FALSE((std::is_move_assignable>::value)); EXPECT_FALSE((std::is_move_assignable>::value)); } TEST(small_storage, holder_copy_move) { struct foo { int i; foo(int i) : i(i) {} foo(foo const &rhs) : i(rhs.i) {} foo(foo &&rhs) : i(std::exchange(rhs.i, 0)) {} }; pmr::allocator alc; pmr::holder h1(alc, 1); pmr::holder h2, h3; // uninitialized h1.copy_to(alc, &h2); EXPECT_EQ(static_cast(h1.get())->i, 1); EXPECT_EQ(static_cast(h2.get())->i, 1); h1.move_to(alc, &h3); EXPECT_EQ(static_cast(h1.get())->i, 0); EXPECT_EQ(static_cast(h3.get())->i, 1); h1.destroy(alc); h2.destroy(alc); h3.destroy(alc); pmr::holder h4(alc, 1); pmr::holder h5, h6; // uninitialized h4.copy_to(alc, &h5); EXPECT_EQ(static_cast(h4.get())->i, 1); EXPECT_EQ(static_cast(h5.get())->i, 1); h4.move_to(alc, &h6); EXPECT_EQ(static_cast(h4.get())->i, 0); EXPECT_EQ(static_cast(h6.get())->i, 1); h4.destroy(alc); h5.destroy(alc); h6.destroy(alc); pmr::holder h7(alc, ::LIBIMP::types{}, 10); pmr::holder h8, h9; // uninitialized h7.copy_to(alc, &h8); EXPECT_EQ(h7.count(), 10); EXPECT_EQ(h8.count(), 10); h7.move_to(alc, &h9); EXPECT_EQ(h7.count(), 0); EXPECT_EQ(h9.count(), 10); h7.destroy(alc); h8.destroy(alc); h9.destroy(alc); } TEST(small_storage, construct) { }