42 #include <gtest/gtest.h> 53 template<
class T,
unsigned int WIDTH,
unsigned int HEIGHT>
54 testing::AssertionResult isNear(
const FixedMatrix<T,WIDTH,HEIGHT> &matrix_a,
55 const FixedMatrix<T,WIDTH,HEIGHT> &matrix_b,
57 for (
unsigned int x=0; x<WIDTH; x++)
for (
unsigned int y=0; y<HEIGHT; y++) {
58 if ((matrix_a(x,y)-matrix_b(x,y) > delta) ||
59 (matrix_b(x,y)-matrix_a(x,y) > delta)) {
60 return testing::AssertionFailure()
61 <<
"The difference of matrix A(" << x <<
", " << y
62 <<
") and matrix B(" << x <<
", " << y <<
") is " << matrix_a(x,y)-matrix_b(x,y)
63 <<
", which exceeds delta, where\nA=\n" << matrix_a <<
"\nB=\n" << matrix_b
64 <<
"\ndelta=" << delta <<
".";
67 return testing::AssertionSuccess();
77 template<
class T,
unsigned int DIM>
78 testing::AssertionResult isNear(
const FixedColVector<T,DIM> &vector_a,
79 const FixedColVector<T,DIM> &vector_b,
81 for (
unsigned int i=0; i<DIM; i++) {
82 if (
abs(vector_a[i]-vector_b[i]) > delta) {
83 return testing::AssertionFailure()
84 <<
"The difference of col vector a[" << i <<
"] and col vector b[" 85 << i <<
"] is " << vector_a[i]-vector_b[i] <<
", which exceeds delta, where\n" 86 <<
"a=" << vector_a.transp() <<
"\nb=" << vector_b.transp()
87 <<
"\ndelta=" << delta <<
".";
91 return testing::AssertionSuccess();
100 template<
class T,
unsigned int DIM>
101 testing::AssertionResult isNear(
const FixedRowVector<T,DIM> &vector_a,
102 const FixedRowVector<T,DIM> &vector_b,
104 for (
unsigned int i=0; i<DIM; i++) {
105 if (
abs(vector_a[i]-vector_b[i]) > delta) {
106 return testing::AssertionFailure()
107 <<
"The difference of row vector a[" << i <<
"] and row vector b[" << i
108 <<
"] is " << vector_a[i]-vector_b[i] <<
", which exceeds delta, where\n" 109 <<
"a=" << vector_a <<
"\nb=" << vector_b
110 <<
"\ndelta=" << delta <<
".";
114 return testing::AssertionSuccess();
121 testing::AssertionResult isNear(
const Point32f &p,
124 float dist =
sqrt((p.x-q.x)*(p.x-q.x) + (p.y-q.y)*(p.y-q.y));
126 return testing::AssertionFailure()
127 <<
"The distance of points " << p <<
" and " << q <<
" is " 128 << dist <<
", which exceeds delta=" << delta <<
".";
130 return testing::AssertionSuccess();
ICLQt_API ImgQ sqrt(const ImgQ &image)
calls sqrt( each pixel)
undocument this line if you encounter any issues!
Definition: Any.h:37
ICLQt_API ImgQ abs(const ImgQ &image)
calls abs ( each pixel)