19 #ifndef itkGTestPredicate_h
20 #define itkGTestPredicate_h
23 #include "gtest/gtest.h"
33 #define ITK_EXPECT_VECTOR_NEAR(val1, val2, rmsError) \
34 EXPECT_PRED_FORMAT3(itk::GTest::Predicate::VectorDoubleRMSPredFormat, val1, val2, rmsError)
56 template <
typename T1,
typename T2>
57 inline ::testing::AssertionResult
60 const char * rmsErrorExpr,
67 if (val1Size != val2Size)
69 return ::testing::AssertionFailure() <<
"The size of " << expr1 <<
" and " << expr2 <<
" different, where\n"
70 << expr1 <<
" evaluates to " << val1 <<
",\n"
71 << expr2 <<
" evaluates to " << val2 <<
'.';
74 for (
unsigned int i = 0; i < val1Size; ++i)
76 const double temp = (val1[i] - val2[i]);
79 const double rms = std::sqrt(total / val1Size);
82 return ::testing::AssertionSuccess();
86 return ::testing::AssertionFailure() <<
"The RMS difference between " << expr1 <<
" and " << expr2 <<
" is " << rms
87 <<
",\n which exceeds " << rmsErrorExpr <<
", where\n"
88 << expr1 <<
" evaluates to " << val1 <<
",\n"
89 << expr2 <<
" evaluates to " << val2 <<
", and\n"
90 << rmsErrorExpr <<
" evaluates to " << rmsError <<
'.';
97 #endif // itkGTestPredicate_h