58 const char * knownValueExpr,
60 const std::string & key,
65#if defined ITK_FUTURE_LEGACY_REMOVE
67 !std::is_same_v<itk::Array<char>, T>,
68 "Should not use the ambiguous 'char' stored in meta data, because it is not-cross platform consistent.");
70 !std::is_same_v<char, T>,
71 "Should not use the ambiguous 'char' stored in meta data, because it is not-cross platform consistent.");
74 return ::testing::AssertionFailure() <<
"Failure ExposeMetaData for key '" << key <<
"' (" << keyExpr <<
") in "
78 if constexpr (std::is_same_v<itk::Array<char>, T>)
82 if constexpr (std::is_signed_v<char>)
87 return ::testing::AssertionFailure()
88 <<
"Failure ExposeMetaData '" << key <<
"' (" << keyExpr <<
") in " << metaDictExpr;
90 exposedValue = temp_value;
97 return ::testing::AssertionFailure()
98 <<
"Failure ExposeMetaData '" << key <<
"' (" << keyExpr <<
") in " << metaDictExpr;
100 exposedValue = temp_value;
104 else if constexpr (std::is_same_v<char, T>)
108 if constexpr (std::is_signed_v<char>)
110 signed char temp_value{};
113 return ::testing::AssertionFailure()
114 <<
"Failure ExposeMetaData '" << key <<
"' (" << keyExpr <<
") in " << metaDictExpr;
116 exposedValue =
static_cast<T
>(temp_value);
120 unsigned char temp_value{};
123 return ::testing::AssertionFailure()
124 <<
"Failure ExposeMetaData '" << key <<
"' (" << keyExpr <<
") in " << metaDictExpr;
126 exposedValue =
static_cast<T
>(temp_value);
132 return ::testing::AssertionFailure() <<
"Failure ExposeMetaData for key '" << key <<
"' (" << keyExpr <<
") in "
138 if constexpr (std::is_floating_point_v<T>)
144 match = (exposedValue == knownValue);
149 return ::testing::AssertionSuccess();
152 ::testing::AssertionResult failure = ::testing::AssertionFailure();
153 failure <<
"Incorrect meta value read in for " << keyExpr <<
" ('" << key <<
"') in " << metaDictExpr <<
"\n"
154 <<
" Actual: " << exposedValue <<
"\n"
155 <<
" Expected: " << knownValue <<
" (" << knownValueExpr <<
")\n";
156 failure <<
"========================================\n";
157 std::stringstream ss;
160 failure <<
"========================================";
175 const char * rmsErrorExpr,
182 if (val1Size != val2Size)
184 return ::testing::AssertionFailure() <<
"The size of " << expr1 <<
" and " << expr2 <<
" different, where\n"
185 << expr1 <<
" evaluates to " << val1 <<
",\n"
186 << expr2 <<
" evaluates to " << val2 <<
'.';
189 for (
unsigned int i = 0; i < val1Size; ++i)
191 const double temp = (val1[i] - val2[i]);
192 total += temp * temp;
194 const double rms = std::sqrt(total / val1Size);
197 return ::testing::AssertionSuccess();
200 return ::testing::AssertionFailure() <<
"The RMS difference between " << expr1 <<
" and " << expr2 <<
" is " << rms
201 <<
",\n which exceeds " << rmsErrorExpr <<
", where\n"
202 << expr1 <<
" evaluates to " << val1 <<
",\n"
203 << expr2 <<
" evaluates to " << val2 <<
", and\n"
204 << rmsErrorExpr <<
" evaluates to " << rmsError <<
'.';
inline ::testing::AssertionResult CheckMetaDataPredFormat(const char *metaDictExpr, const char *keyExpr, const char *knownValueExpr, itk::MetaDataDictionary &metaDict, const std::string &key, const T &knownValue)