diff --git a/util/testharness.cc b/util/testharness.cc index 96df1eb2e..603f6f6e1 100644 --- a/util/testharness.cc +++ b/util/testharness.cc @@ -13,6 +13,15 @@ namespace rocksdb { namespace test { +::testing::AssertionResult AssertStatus(const char* s_expr, const Status& s) { + if (s.ok()) { + return ::testing::AssertionSuccess(); + } else { + return ::testing::AssertionFailure() << s_expr << std::endl + << s.ToString(); + } +} + std::string TmpDir(Env* env) { std::string dir; Status s = env->GetTestDirectory(&dir); diff --git a/util/testharness.h b/util/testharness.h index 1600ff3e1..b212b1e3a 100644 --- a/util/testharness.h +++ b/util/testharness.h @@ -25,10 +25,12 @@ std::string TmpDir(Env* env = Env::Default()); // runs may be able to vary the seed. int RandomSeed(); -#define ASSERT_OK(s) ASSERT_TRUE(((s).ok())) -#define ASSERT_NOK(s) ASSERT_FALSE(((s).ok())) -#define EXPECT_OK(s) EXPECT_TRUE(((s).ok())) -#define EXPECT_NOK(s) EXPECT_FALSE(((s).ok())) +::testing::AssertionResult AssertStatus(const char* s_expr, const Status& s); + +#define ASSERT_OK(s) ASSERT_PRED_FORMAT1(rocksdb::test::AssertStatus, s) +#define ASSERT_NOK(s) ASSERT_FALSE((s).ok()) +#define EXPECT_OK(s) EXPECT_PRED_FORMAT1(rocksdb::test::AssertStatus, s) +#define EXPECT_NOK(s) EXPECT_FALSE((s).ok()) } // namespace test } // namespace rocksdb