Additional tests for Nullable<T> (#2215)

Closes #1786
This commit is contained in:
Anton Kolesnyk 2021-05-07 16:11:41 +00:00 committed by GitHub
parent 941b67178e
commit 43ee2ee192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,3 +207,20 @@ TEST(Nullable, PreCondition3)
ASSERT_DEATH(Foo(Nullable<int>().Value());, "Empty Nullable");
#endif
}
TEST(Nullable, Operator)
{
Nullable<std::string> val1("12345");
EXPECT_EQ(*val1, "12345");
val1->append("aaaa");
EXPECT_EQ(*val1, "12345aaaa");
}
TEST(Nullable, Move)
{
Nullable<std::unique_ptr<int>> val(std::make_unique<int>(123));
std::unique_ptr<int> const taken = *std::move(val);
EXPECT_TRUE(taken);
EXPECT_EQ(*taken, 123);
// val.HasValue() would return true, but accessing a value after it has been moved is UB anyways.
}