void expectNear(const M1 & A, const M2 & B, T tolerance, std::string const & message = "") { EXPECT_EQ((size_t)A.rows(),(size_t)B.rows()) << message << "\nMatrix A:\n" << A << "\nand matrix B\n" << B << "\nare not the same\n"; EXPECT_EQ((size_t)A.cols(),(size_t)B.cols()) << message << "\nMatrix A:\n" << A << "\nand matrix B\n" << B << "\nare not the same\n"; for(int r = 0; r < A.rows(); r++) { for(int c = 0; c < A.cols(); c++) { EXPECT_NEAR(A(r,c),B(r,c),tolerance) << message << "\nTolerance comparison failed at (" << r << "," << c << ")\n" << "\nMatrix A:\n" << A << "\nand matrix B\n" << B; } } }
void assertEqual(const M1 & A, const M2 & B, std::string const & message = "") { ASSERT_EQ((size_t)A.rows(),(size_t)B.rows()) << message << "\nMatrix A:\n" << A << "\nand matrix B\n" << B << "\nare not the same\n"; ASSERT_EQ((size_t)A.cols(),(size_t)B.cols()) << message << "\nMatrix A:\n" << A << "\nand matrix B\n" << B << "\nare not the same\n"; for(int r = 0; r < A.rows(); r++) { for(int c = 0; c < A.cols(); c++) { ASSERT_EQ(A(r,c),B(r,c)) << message << "\nEquality comparison failed at (" << r << "," << c << ")\n" << "\nMatrix A:\n" << A << "\nand matrix B\n" << B; } } }
void assertNear(const M1 & A, const M2 & B, T tolerance, std::string const & message = "") { // Note: If these assertions fail, they only abort this subroutine. // see: http://code.google.com/p/googletest/wiki/AdvancedGuide#Using_Assertions_in_Sub-routines // \todo better handling of this ASSERT_EQ((size_t)A.rows(),(size_t)B.rows()) << message << "\nMatrix A:\n" << A << "\nand matrix B\n" << B << "\nare not the same\n"; ASSERT_EQ((size_t)A.cols(),(size_t)B.cols()) << message << "\nMatrix A:\n" << A << "\nand matrix B\n" << B << "\nare not the same\n"; for(int r = 0; r < A.rows(); r++) { for(int c = 0; c < A.cols(); c++) { ASSERT_NEAR(A(r,c),B(r,c),tolerance) << message << "\nTolerance comparison failed at (" << r << "," << c << ")\n" << "\nMatrix A:\n" << A << "\nand matrix B\n" << B; } } }