testing ASSERT_OK and ASSERT_OK_AND_ASSIGN macros

This commit is contained in:
scawful
2024-08-14 00:51:08 -04:00
parent 5d9c5354b0
commit c7afbb3458

View File

@@ -9,11 +9,21 @@
#define EXPECT_OK(expr) EXPECT_EQ((expr), absl::OkStatus())
#define ASSERT_OK(expr) ASSERT_EQ((expr), absl::OkStatus())
#define ASSERT_OK_AND_ASSIGN(lhs, rexpr) \
if (auto rexpr_value = (rexpr); rexpr_value.ok()) { \
lhs = std::move(rexpr_value).value(); \
} else { \
FAIL() << "error: " << rexpr_value.status(); \
}
namespace yaze {
namespace test {
// StatusIs is a matcher that matches a status that has the same code and
// message as the expected status.
MATCHER_P(StatusIs, status, "") { return arg.code() == status; }
MATCHER_P(StatusIs, status, "") {
return arg.code() == status;
}