19 #ifndef itkGTestPredicate_h
20 #define itkGTestPredicate_h
23 #include "gtest/gtest.h"
33 #define EXPECT_VECTOR_NEAR(val1, val2, rmsError) \
34 EXPECT_PRED_FORMAT3(itk::GTest::Predicate::VectorDoubleRMSPredFormat, \
57 template<
typename T1,
typename T2>
60 const char* rmsErrorExpr,
65 const size_t val1Size = itk::NumericTraits<T1>::GetLength(val1);
66 const size_t val2Size = itk::NumericTraits<T2>::GetLength(val2);
67 if ( val1Size != val2Size )
69 return ::testing::AssertionFailure()
70 <<
"The size of " << expr1 <<
" and " << expr2
71 <<
" different, where\n"
72 << expr1 <<
" evaluates to " << val1 <<
",\n"
73 << expr2 <<
" evaluates to " << val2 <<
".";
78 for (
unsigned int i = 0; i < val1Size; ++i )
80 const double temp = (val1[i]-val2[i]);
83 const double rms = std::sqrt(total/val1Size);
86 return ::testing::AssertionSuccess();
89 return ::testing::AssertionFailure()
90 <<
"The RMS difference between " << expr1 <<
" and " << expr2
91 <<
" is " << rms <<
",\n which exceeds " << rmsErrorExpr <<
", where\n"
92 << expr1 <<
" evaluates to " << val1 <<
",\n"
93 << expr2 <<
" evaluates to " << val2 <<
", and\n"
94 << rmsErrorExpr <<
" evaluates to " << rmsError <<
".";
101 #endif // itkGTestPredicate_h
inline::testing::AssertionResult VectorDoubleRMSPredFormat(const char *expr1, const char *expr2, const char *rmsErrorExpr, const T1 &val1, const T2 &val2, double rmsError)