Remove use of ASSERT_THAT
This commit is contained in:
parent
4c658d7811
commit
78a4c6d730
5 changed files with 53 additions and 54 deletions
|
|
@ -9,25 +9,25 @@ Expected<int> getAnswerToEverything() { return 42; }
|
|||
TEST(expected, valid_when_valid_returns_true)
|
||||
{
|
||||
Expected<int> v = getAnswerToEverything();
|
||||
ASSERT_THAT(v.valid(), Eq(true));
|
||||
ASSERT_TRUE(v.valid());
|
||||
}
|
||||
|
||||
TEST(expected, get_when_valid_returns_value)
|
||||
{
|
||||
Expected<int> v = getAnswerToEverything();
|
||||
ASSERT_THAT(v.get(), Eq(42));
|
||||
ASSERT_EQ(v.get(), 42);
|
||||
}
|
||||
|
||||
TEST(expected, hasException_when_valid_returns_false)
|
||||
{
|
||||
Expected<int> v = getAnswerToEverything();
|
||||
ASSERT_THAT(v.hasException<std::exception>(), Eq(false));
|
||||
ASSERT_FALSE(v.hasException<std::exception>());
|
||||
}
|
||||
|
||||
TEST(expected, T_fromException_is_not_valid)
|
||||
{
|
||||
auto e = Expected<int>::fromException(std::runtime_error("hello"));
|
||||
ASSERT_THAT(e.valid(), Eq(false));
|
||||
ASSERT_FALSE(e.valid());
|
||||
}
|
||||
|
||||
TEST(expected, T_fromException_get_thows)
|
||||
|
|
@ -39,38 +39,38 @@ TEST(expected, T_fromException_get_thows)
|
|||
TEST(expected, T_fromException_has_exception_true)
|
||||
{
|
||||
auto e = Expected<int>::fromException(std::runtime_error("hello"));
|
||||
ASSERT_THAT(e.hasException<std::runtime_error>(), Eq(true));
|
||||
ASSERT_TRUE(e.hasException<std::runtime_error>());
|
||||
}
|
||||
|
||||
TEST(expected, T_fromException_has_exception_false)
|
||||
{
|
||||
auto e = Expected<int>::fromException(std::runtime_error("hello"));
|
||||
ASSERT_THAT(e.hasException<std::logic_error>(), Eq(false));
|
||||
ASSERT_FALSE(e.hasException<std::logic_error>());
|
||||
}
|
||||
|
||||
TEST(expected, T_fromException_has_derived_exception)
|
||||
{
|
||||
auto e = Expected<int>::fromException(std::runtime_error("hello"));
|
||||
ASSERT_THAT(e.hasException<std::exception>(), Eq(true));
|
||||
ASSERT_TRUE(e.hasException<std::exception>());
|
||||
}
|
||||
|
||||
TEST(expected, T_fromCode_is_valid)
|
||||
{
|
||||
auto e = Expected<int>::fromCode([]() -> int { return 42; });
|
||||
ASSERT_THAT(e.valid(), Eq(true));
|
||||
ASSERT_TRUE(e.valid());
|
||||
}
|
||||
|
||||
TEST(expected, T_fromCode_get)
|
||||
{
|
||||
auto e = Expected<int>::fromCode([]() -> int { return 42; });
|
||||
ASSERT_THAT(e.get(), Eq(42));
|
||||
ASSERT_EQ(e.get(), 42);
|
||||
}
|
||||
|
||||
|
||||
TEST(expected, T_fromCode_E_is_not_valid)
|
||||
{
|
||||
auto e = Expected<int>::fromCode([]() -> int { throw std::runtime_error("hello"); });
|
||||
ASSERT_THAT(e.valid(), Eq(false));
|
||||
ASSERT_FALSE(e.valid());
|
||||
}
|
||||
|
||||
TEST(expected, T_fromCode_E_get_thows)
|
||||
|
|
@ -82,19 +82,19 @@ TEST(expected, T_fromCode_E_get_thows)
|
|||
TEST(expected, T_fromCode_E_has_exception_true)
|
||||
{
|
||||
auto e = Expected<int>::fromCode([]() -> int { throw std::runtime_error("hello"); });
|
||||
ASSERT_THAT(e.hasException<std::runtime_error>(), Eq(true));
|
||||
ASSERT_TRUE(e.hasException<std::runtime_error>());
|
||||
}
|
||||
|
||||
TEST(expected, T_fromCode_E_has_exception_false)
|
||||
{
|
||||
auto e = Expected<int>::fromCode([]() -> int { throw std::runtime_error("hello"); });
|
||||
ASSERT_THAT(e.hasException<std::logic_error>(), Eq(false));
|
||||
ASSERT_FALSE(e.hasException<std::logic_error>());
|
||||
}
|
||||
|
||||
TEST(expected, T_fromCode_E_has_derived_exception)
|
||||
{
|
||||
auto e = Expected<int>::fromCode([]() -> int { throw std::runtime_error("hello"); });
|
||||
ASSERT_THAT(e.hasException<std::exception>(), Eq(true));
|
||||
ASSERT_TRUE(e.hasException<std::exception>());
|
||||
}
|
||||
|
||||
//Expected<int> getIntWithStdRuntimeError() { return Expected<void>(); }
|
||||
|
|
@ -105,7 +105,7 @@ Expected<void> getNothing() { return Expected<void>(); }
|
|||
TEST(expected_void, valid_when_valid_returns_true)
|
||||
{
|
||||
Expected<void> v = getNothing();
|
||||
ASSERT_THAT(v.valid(), Eq(true));
|
||||
ASSERT_TRUE(v.valid());
|
||||
}
|
||||
|
||||
TEST(expected_void, get_when_valid_returns_value)
|
||||
|
|
@ -117,7 +117,7 @@ TEST(expected_void, get_when_valid_returns_value)
|
|||
TEST(expected_void, hasException_when_valid_returns_false)
|
||||
{
|
||||
Expected<void> v = getNothing();
|
||||
ASSERT_THAT(v.hasException<std::exception>(), Eq(false));
|
||||
ASSERT_FALSE(v.hasException<std::exception>());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue