Add tests for direct (move) assignments

This commit is contained in:
Sebastian Messmer 2015-06-26 02:02:29 +02:00
parent 396dbcfc1c
commit 99be93d970
1 changed files with 24 additions and 0 deletions

View File

@ -201,6 +201,30 @@ TEST_F(EitherTest, RightCanBeMoveAssigned) {
EXPECT_EQ(3, val2.right().value);
}
TEST_F(EitherTest, LeftCanBeDirectlyAssigned) {
Either<string, int> val = string("string");
val = string("otherstring");
EXPECT_LEFT_IS("otherstring", val);
}
TEST_F(EitherTest, RightCanBeDirectlyAssigned) {
Either<int, string> val = string("string");
val = string("otherstring");
EXPECT_RIGHT_IS("otherstring", val);
}
TEST_F(EitherTest, LeftCanBeDirectlyMoveAssigned) {
Either<OnlyMoveable, int> val = OnlyMoveable(3);
val = OnlyMoveable(5);
EXPECT_EQ(5, val.left().value);
}
TEST_F(EitherTest, RightCanBeDirectlyMoveAssigned) {
Either<int, OnlyMoveable> val = OnlyMoveable(3);
val = OnlyMoveable(5);
EXPECT_EQ(5, val.right().value);
}
TEST_F(EitherTest, ModifyLeft) {
Either<string, int> val = string("mystring1");
val.left() = "mystring2";