other macros

This commit is contained in:
Enrico Scalabrino 2024-01-10 21:55:28 +01:00
parent f670886941
commit df805151fa

View file

@ -1865,18 +1865,80 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
// ASSERT_LT(i, array_size);
// ASSERT_GT(records.size(), 0) << "There is no record left.";
#define EXPECT_EQ(val1, val2) \
EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
#define EXPECT_NE(val1, val2) \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
#define EXPECT_LE(val1, val2) \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
#define EXPECT_LT(val1, val2) \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
#define EXPECT_GE(val1, val2) \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
#define EXPECT_GT(val1, val2) \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
#define EXPECT_EQ(val1, val2) \
do { \
const auto& gtest_retval = ::testing::internal::EqHelper::Compare( \
#val1, #val2, static_cast<decltype(val1)>(val1), \
static_cast<decltype(val2)>(val2)); \
if (gtest_retval == ::testing::AssertionSuccess()) { \
std::cout << "Success: Test Name: " << ::testing::UnitTest::GetInstance()->current_test_info()->name() << ", " \
<< #val1 << ": " << val1 << ", " << #val2 << ": " << val2 << std::endl; \
} else { \
EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2); \
} \
} while (0)
#define EXPECT_NE(val1, val2) \
do { \
const auto& gtest_retval = ::testing::internal::CmpHelperNE( \
#val1, #val2, static_cast<decltype(val1)>(val1), \
static_cast<decltype(val2)>(val2)); \
if (gtest_retval == ::testing::AssertionSuccess()) { \
std::cout << "Success: Test Name: " << ::testing::UnitTest::GetInstance()->current_test_info()->name() << ", " \
<< #val1 << ": " << val1 << ", " << #val2 << ": " << val2 << std::endl; \
} else { \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2); \
} \
} while (0)
#define EXPECT_LE(val1, val2) \
do { \
const auto& gtest_retval = ::testing::internal::CmpHelperLE( \
#val1, #val2, static_cast<decltype(val1)>(val1), \
static_cast<decltype(val2)>(val2)); \
if (gtest_retval == ::testing::AssertionSuccess()) { \
std::cout << "Success: Test Name: " << ::testing::UnitTest::GetInstance()->current_test_info()->name() << ", " \
<< #val1 << ": " << val1 << ", " << #val2 << ": " << val2 << std::endl; \
} else { \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2); \
} \
} while (0)
#define EXPECT_LT(val1, val2) \
do { \
const auto& gtest_retval = ::testing::internal::CmpHelperLT( \
#val1, #val2, static_cast<decltype(val1)>(val1), \
static_cast<decltype(val2)>(val2)); \
if (gtest_retval == ::testing::AssertionSuccess()) { \
std::cout << "Success: Test Name: " << ::testing::UnitTest::GetInstance()->current_test_info()->name() << ", " \
<< #val1 << ": " << val1 << ", " << #val2 << ": " << val2 << std::endl; \
} else { \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2); \
} \
} while (0)
#define EXPECT_GE(val1, val2) \
do { \
const auto& gtest_retval = ::testing::internal::CmpHelperGE( \
#val1, #val2, static_cast<decltype(val1)>(val1), \
static_cast<decltype(val2)>(val2)); \
if (gtest_retval == ::testing::AssertionSuccess()) { \
std::cout << "Success: Test Name: " << ::testing::UnitTest::GetInstance()->current_test_info()->name() << ", " \
<< #val1 << ": " << val1 << ", " << #val2 << ": " << val2 << std::endl; \
} else { \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2); \
} \
} while (0)
#define EXPECT_GT(val1, val2) \
do { \
const auto& gtest_retval = ::testing::internal::CmpHelperGT( \
#val1, #val2, static_cast<decltype(val1)>(val1), \
static_cast<decltype(val2)>(val2)); \
if (gtest_retval == ::testing::AssertionSuccess()) { \
std::cout << "Success: Test Name: " << ::testing::UnitTest::GetInstance()->current_test_info()->name() << ", " \
<< #val1 << ": " << val1 << ", "
#define GTEST_ASSERT_EQ(val1, val2) \
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)