From 55463e6b79bd99143ffb71b3506d71ccd217057c Mon Sep 17 00:00:00 2001 From: Tamas Petz Date: Tue, 23 Jan 2024 12:18:55 +0100 Subject: [PATCH] [test] Change printing mismatches in framework The new prints show hexadecimal values with base, instead of printing non-visible characters. --- test/framework/array.h | 32 +++++++++++++++++--------------- test/framework/test_array2d.cpp | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/test/framework/array.h b/test/framework/array.h index 1b392ad65..4a566053a 100644 --- a/test/framework/array.h +++ b/test/framework/array.h @@ -309,21 +309,23 @@ class Array2D : public TwoDimensional { }; // end of class Array2D /// Compares two \ref Array2D objects for equality. -#define EXPECT_EQ_ARRAY2D(lhs, rhs) \ - do { \ - ASSERT_EQ((lhs).width(), (rhs).width()) \ - << "Mismatch in width." << std::endl; \ - ASSERT_EQ((lhs).height(), (rhs).height()) \ - << "Mismatch in height." << std::endl; \ - ASSERT_EQ((lhs).channels(), (rhs).channels()) \ - << "Mismatch in channels." << std::endl; \ - auto mismatch = (lhs).compare_to((rhs)); \ - if (mismatch) { \ - auto [row, col] = *mismatch; \ - GTEST_FAIL() << "Mismatch at (row=" << row << ", col=" << col \ - << "): " << (lhs).at(row, col)[0] << " vs " \ - << (rhs).at(row, col)[0] << "." << std::endl; \ - } \ +#define EXPECT_EQ_ARRAY2D(lhs, rhs) \ + do { \ + ASSERT_EQ((lhs).width(), (rhs).width()) \ + << "Mismatch in width." << std::endl; \ + ASSERT_EQ((lhs).height(), (rhs).height()) \ + << "Mismatch in height." << std::endl; \ + ASSERT_EQ((lhs).channels(), (rhs).channels()) \ + << "Mismatch in channels." << std::endl; \ + auto mismatch = (lhs).compare_to((rhs)); \ + if (mismatch) { \ + auto [row, col] = *mismatch; \ + GTEST_FAIL() << "Mismatch at (row=" << row << ", col=" << col \ + << "): " << std::hex << std::showbase \ + << static_cast((lhs).at(row, col)[0]) << " vs " \ + << static_cast((rhs).at(row, col)[0]) << "." \ + << std::endl; \ + } \ } while (0 != 0) /// Compares two \ref Array2D objects for inequality. diff --git a/test/framework/test_array2d.cpp b/test/framework/test_array2d.cpp index a26c25bd1..adbeaa7cd 100644 --- a/test/framework/test_array2d.cpp +++ b/test/framework/test_array2d.cpp @@ -296,7 +296,7 @@ TEST(Array2D, ExpectEq_NotEqual_Data) { } }; - EXPECT_FATAL_FAILURE(Test::test(), "Mismatch at (row=0, col=0): 0 vs 42."); + EXPECT_FATAL_FAILURE(Test::test(), "Mismatch at (row=0, col=0): 0 vs 0x2a."); } /// Tests that EXPECT_NE_ARRAY2D() macro works for equal objects. -- GitLab