MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / assertImageEq

Function assertImageEq

test/arrayfire_test.cpp:251–286  ·  view source on GitHub ↗

Called by ASSERT_ARRAYS_EQ

Source from the content-addressed store, hash-verified

249
250// Called by ASSERT_ARRAYS_EQ
251::testing::AssertionResult assertImageEq(std::string aName, std::string bName,
252 const af::array &a, const af::array &b,
253 float maxAbsDiff) {
254 af::dtype aType = a.type();
255 af::dtype bType = b.type();
256 if (aType != bType)
257 return ::testing::AssertionFailure()
258 << "TYPE MISMATCH: \n"
259 << " Actual: " << bName << "(" << b.type() << ")\n"
260 << "Expected: " << aName << "(" << a.type() << ")";
261
262 af::dtype arrDtype = aType;
263 if (a.dims() != b.dims())
264 return ::testing::AssertionFailure()
265 << "SIZE MISMATCH: \n"
266 << " Actual: " << bName << "([" << b.dims() << "])\n"
267 << "Expected: " << aName << "([" << a.dims() << "])";
268
269 switch (arrDtype) {
270 case s8: return imageEq<signed char>(aName, bName, a, b, maxAbsDiff);
271 case u8: return imageEq<unsigned char>(aName, bName, a, b, maxAbsDiff);
272 case b8: return imageEq<char>(aName, bName, a, b, maxAbsDiff);
273 case s32: return imageEq<int>(aName, bName, a, b, maxAbsDiff);
274 case u32: return imageEq<unsigned int>(aName, bName, a, b, maxAbsDiff);
275 case f32: return imageEq<float>(aName, bName, a, b, maxAbsDiff);
276 case f64: return imageEq<double>(aName, bName, a, b, maxAbsDiff);
277 case s16: return imageEq<short>(aName, bName, a, b, maxAbsDiff);
278 case u16:
279 return imageEq<unsigned short>(aName, bName, a, b, maxAbsDiff);
280 case u64:
281 return imageEq<unsigned long long>(aName, bName, a, b, maxAbsDiff);
282 case s64: return imageEq<long long>(aName, bName, a, b, maxAbsDiff);
283 default: throw(AF_ERR_NOT_SUPPORTED);
284 }
285 return ::testing::AssertionSuccess();
286}
287
288template<>
289float convert(af::half in) {

Callers 1

assertImageNearFunction · 0.85

Calls 2

typeMethod · 0.80
dimsMethod · 0.45

Tested by

no test coverage detected