mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06:44 +08:00
Add tests for move assignment
This commit is contained in:
parent
7fda8b9f65
commit
3d6bb4d8a7
@ -121,7 +121,7 @@ struct expected_move_base {
|
|||||||
expected_move_base& operator=(expected_move_base const&) = default;
|
expected_move_base& operator=(expected_move_base const&) = default;
|
||||||
expected_move_base& operator=(expected_move_base&& right) {
|
expected_move_base& operator=(expected_move_base&& right) {
|
||||||
Base& me = *static_cast<Base*>(this);
|
Base& me = *static_cast<Base*>(this);
|
||||||
Base const& other = *static_cast<Base*>(&right);
|
Base& other = *static_cast<Base*>(&right);
|
||||||
|
|
||||||
me.weak_destroy();
|
me.weak_destroy();
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,7 @@ TYPED_TEST_CASE(expected_all_tests, expected_test_types);
|
|||||||
TYPED_TEST(expected_all_tests, can_carry_errors) {
|
TYPED_TEST(expected_all_tests, can_carry_errors) {
|
||||||
{
|
{
|
||||||
TypeParam e(this->supply(CANARY));
|
TypeParam e(this->supply(CANARY));
|
||||||
|
|
||||||
EXPECT_TRUE(bool(e));
|
EXPECT_TRUE(bool(e));
|
||||||
EXPECT_EQ(this->get(*e), CANARY);
|
EXPECT_EQ(this->get(*e), CANARY);
|
||||||
EXPECT_TRUE(e.is_value());
|
EXPECT_TRUE(e.is_value());
|
||||||
@ -74,6 +75,7 @@ TYPED_TEST(expected_all_tests, can_carry_errors) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
TypeParam e(error_type{});
|
TypeParam e(error_type{});
|
||||||
|
|
||||||
EXPECT_FALSE(bool(e));
|
EXPECT_FALSE(bool(e));
|
||||||
EXPECT_FALSE(e.is_value());
|
EXPECT_FALSE(e.is_value());
|
||||||
EXPECT_TRUE(e.is_error());
|
EXPECT_TRUE(e.is_error());
|
||||||
@ -88,6 +90,7 @@ TYPED_TEST(expected_all_tests, is_empty_constructible) {
|
|||||||
TYPED_TEST(expected_all_tests, is_move_constructible) {
|
TYPED_TEST(expected_all_tests, is_move_constructible) {
|
||||||
{
|
{
|
||||||
TypeParam e(TypeParam(this->supply(CANARY)));
|
TypeParam e(TypeParam(this->supply(CANARY)));
|
||||||
|
|
||||||
EXPECT_TRUE(bool(e));
|
EXPECT_TRUE(bool(e));
|
||||||
EXPECT_EQ(this->get(*e), CANARY);
|
EXPECT_EQ(this->get(*e), CANARY);
|
||||||
EXPECT_TRUE(e.is_value());
|
EXPECT_TRUE(e.is_value());
|
||||||
@ -102,10 +105,34 @@ TYPED_TEST(expected_all_tests, is_move_constructible) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TYPED_TEST(expected_all_tests, is_move_assignable) {
|
||||||
|
{
|
||||||
|
TypeParam old(this->supply(CANARY));
|
||||||
|
TypeParam e;
|
||||||
|
e = std::move(old);
|
||||||
|
|
||||||
|
EXPECT_TRUE(bool(e));
|
||||||
|
EXPECT_EQ(this->get(*e), CANARY);
|
||||||
|
EXPECT_TRUE(e.is_value());
|
||||||
|
EXPECT_FALSE(e.is_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
TypeParam old(error_type{});
|
||||||
|
TypeParam e;
|
||||||
|
e = std::move(old);
|
||||||
|
|
||||||
|
EXPECT_FALSE(bool(e));
|
||||||
|
EXPECT_FALSE(e.is_value());
|
||||||
|
EXPECT_TRUE(e.is_error());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST(expected_copyable_tests, is_copy_constructible) {
|
TEST(expected_copyable_tests, is_copy_constructible) {
|
||||||
{
|
{
|
||||||
copyable_type const e_old(CANARY);
|
copyable_type const e_old(CANARY);
|
||||||
copyable_type e(e_old);
|
copyable_type e(e_old);
|
||||||
|
|
||||||
EXPECT_TRUE(bool(e));
|
EXPECT_TRUE(bool(e));
|
||||||
EXPECT_EQ(*e, CANARY);
|
EXPECT_EQ(*e, CANARY);
|
||||||
EXPECT_TRUE(e.is_value());
|
EXPECT_TRUE(e.is_value());
|
||||||
@ -115,6 +142,30 @@ TEST(expected_copyable_tests, is_copy_constructible) {
|
|||||||
{
|
{
|
||||||
copyable_type const e_old(error_type{});
|
copyable_type const e_old(error_type{});
|
||||||
copyable_type e(e_old);
|
copyable_type e(e_old);
|
||||||
|
|
||||||
|
EXPECT_FALSE(bool(e));
|
||||||
|
EXPECT_FALSE(e.is_value());
|
||||||
|
EXPECT_TRUE(e.is_error());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(expected_copyable_tests, is_copy_assignable) {
|
||||||
|
{
|
||||||
|
copyable_type const e_old(CANARY);
|
||||||
|
copyable_type e;
|
||||||
|
e = e_old;
|
||||||
|
|
||||||
|
EXPECT_TRUE(bool(e));
|
||||||
|
EXPECT_EQ(*e, CANARY);
|
||||||
|
EXPECT_TRUE(e.is_value());
|
||||||
|
EXPECT_FALSE(e.is_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
copyable_type const e_old(error_type{});
|
||||||
|
copyable_type e;
|
||||||
|
e = e_old;
|
||||||
|
|
||||||
EXPECT_FALSE(bool(e));
|
EXPECT_FALSE(bool(e));
|
||||||
EXPECT_FALSE(e.is_value());
|
EXPECT_FALSE(e.is_value());
|
||||||
EXPECT_TRUE(e.is_error());
|
EXPECT_TRUE(e.is_error());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user