24 #ifndef _COMPAREIMAGES_H
25 #define _COMPAREIMAGES_H
28 #include <boost/test/predicate_result.hpp>
32 template <
typename T,
typename U>
34 const T& ref,
const U& val,
double atol = 1e-8,
double rtol = 1e-5) {
35 boost::test_tools::predicate_result res(
true);
37 if (
ref->getWidth() != val->getWidth() ||
ref->getHeight() != val->getHeight()) {
39 res.message() <<
"Images do not match in size: "
40 <<
ref->getWidth() <<
'x' <<
ref->getHeight() <<
" vs "
41 << val->getWidth() <<
'x' << val->getHeight();
44 int w =
ref->getWidth(), h =
ref->getHeight();
45 auto ref_chunk =
ref->getChunk(0, 0, w, h);
46 auto val_chunk = val->getChunk(0, 0, w, h);
48 for (
int x = 0;
x <
ref->getWidth(); ++
x) {
49 for (
int y = 0;
y <
ref->getHeight(); ++
y) {
50 auto expected = ref_chunk->getValue(
x,
y);
51 auto value = val_chunk->getValue(
x,
y);
54 res.message() <<
"Not matching values at position " <<
x <<
"," <<
y
55 <<
": " << expected <<
" != " << value <<
"\n";
63 template <
typename T,
typename U>
65 const T& ref,
const U& val,
double atol = 1e-8,
double rtol = 1e-5) {
66 boost::test_tools::predicate_result res(
true);
76 res.message() <<
"Not matching values at position " << i <<
": " << *ref_i <<
" != " << *val_i <<
"\n";
86 res.message() <<
"The sequences have different length!" <<
"\n";
92 boost::test_tools::predicate_result
checkIsClose(
double ref,
const double val,
double atol = 1e-8,
double rtol = 1e-5) {
93 boost::test_tools::predicate_result res(
true);
96 res.message() <<
"Values not close enough: " <<
ref <<
" " << val <<
" with absolute tolerance " <<
atol
97 <<
" and relative " << rtol <<
"\n";
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y