From a267138d7063b18ed15cf65de513fff7c1a15470 Mon Sep 17 00:00:00 2001 From: scawful Date: Wed, 14 Aug 2024 00:31:47 -0400 Subject: [PATCH] add EXPECT_OK and StatusIs gtest matcher --- src/test/core/testing.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/core/testing.h diff --git a/src/test/core/testing.h b/src/test/core/testing.h new file mode 100644 index 00000000..1a878f9b --- /dev/null +++ b/src/test/core/testing.h @@ -0,0 +1,24 @@ +#ifndef YAZE_TEST_CORE_TESTING_H +#define YAZE_TEST_CORE_TESTING_H + +#include +#include + +#include "absl/status/status.h" +#include "absl/status/statusor.h" + +#define EXPECT_OK(expr) EXPECT_EQ((expr), absl::OkStatus()) + +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; +} + +} // namespace test +} // namespace yaze + +#endif // YAZE_TEST_CORE_TESTING_H \ No newline at end of file