Don't flood test output with successful VERIFY_IS_NOT_EQUAL tests.

This commit is contained in:
Christoph Hertzberg 2016-05-11 19:40:45 +02:00
parent bda21407dd
commit 8d4ef391b0

View File

@ -279,8 +279,8 @@ inline void verify_impl(bool condition, const char *testname, const char *file,
#define VERIFY_LE(a, b) ::verify_impl(a <= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EI_PP_MAKE_STRING(a <= b)) #define VERIFY_LE(a, b) ::verify_impl(a <= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EI_PP_MAKE_STRING(a <= b))
#define VERIFY_IS_EQUAL(a, b) VERIFY(test_is_equal(a, b)) #define VERIFY_IS_EQUAL(a, b) VERIFY(test_is_equal(a, b, true))
#define VERIFY_IS_NOT_EQUAL(a, b) VERIFY(!test_is_equal(a, b)) #define VERIFY_IS_NOT_EQUAL(a, b) VERIFY(test_is_equal(a, b, false))
#define VERIFY_IS_APPROX(a, b) VERIFY(verifyIsApprox(a, b)) #define VERIFY_IS_APPROX(a, b) VERIFY(verifyIsApprox(a, b))
#define VERIFY_IS_NOT_APPROX(a, b) VERIFY(!test_isApprox(a, b)) #define VERIFY_IS_NOT_APPROX(a, b) VERIFY(!test_isApprox(a, b))
#define VERIFY_IS_MUCH_SMALLER_THAN(a, b) VERIFY(test_isMuchSmallerThan(a, b)) #define VERIFY_IS_MUCH_SMALLER_THAN(a, b) VERIFY(test_isMuchSmallerThan(a, b))
@ -517,17 +517,17 @@ inline bool test_isUnitary(const MatrixBase<Derived>& m)
// Forward declaration to avoid ICC warning // Forward declaration to avoid ICC warning
template<typename T, typename U> template<typename T, typename U>
bool test_is_equal(const T& actual, const U& expected); bool test_is_equal(const T& actual, const U& expected, bool expect_equal=true);
template<typename T, typename U> template<typename T, typename U>
bool test_is_equal(const T& actual, const U& expected) bool test_is_equal(const T& actual, const U& expected, bool expect_equal)
{ {
if (actual==expected) if ((actual==expected) == expect_equal)
return true; return true;
// false: // false:
std::cerr std::cerr
<< std::endl << " actual = " << actual << "\n actual = " << actual
<< std::endl << " expected = " << expected << std::endl << std::endl; << "\n expected " << (expect_equal ? "= " : "!=") << expected << "\n\n";
return false; return false;
} }