DMRITool
v0.1.1-139-g860d86b4
Diffusion MRI Tool
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
Modules
HelperFunctions
include
utlGTest.h
Go to the documentation of this file.
1
17
#ifndef __utlGTest_h
18
#define __utlGTest_h
19
20
#include "gtest/gtest.h"
21
25
#define EXPECT_NEAR_COMPLEX(val1, val2, eps) \
26
do { EXPECT_NEAR(std::abs(val1-val2), 0.0, eps) << "val1="<<val1 <<", val2=" <<val2; } while(0)
27
28
#define EXPECT_NEAR_RELATIVE(val1, val2, eps) \
29
do { EXPECT_NEAR(val1,val2, eps*std::fabs(val2)); } while (0)
30
31
#define EXPECT_NEAR_VECTOR_COMPLEX(vec1, vec2, N, eps) \
32
do { for ( int i = 0; i < N; i += 1 ) \
33
EXPECT_NEAR(std::abs((vec1)[i]-(vec2)[i]), 0, eps) << "index = " << i << ", vec1[i]="<<vec1[i] <<", vec2[i]=" <<vec2[i]; } while (0)
34
35
#define EXPECT_NEAR_VECTOR(vec1, vec2, N, eps) \
36
do { for ( int i = 0; i < N; i += 1 ) \
37
EXPECT_NEAR((vec1)[i], (vec2)[i], eps) << "index = " << i; } while (0)
38
39
#define EXPECT_NEAR_MATRIX_COMPLEX(mat1, mat2, Row, Col, eps) \
40
do { for ( int i = 0; i < Row; i += 1 ) \
41
for ( int j = 0; j < Col; j += 1 ) \
42
EXPECT_NEAR(std::abs((mat1)(i,j)-(mat2)(i,j)), 0, eps) << "index = ("<< i<<","<<j<<"), mat1(i,j)=" << mat1(i,j) << ", mat2(i,j)=" << mat2(i,j); } while (0)
43
44
#define EXPECT_NEAR_MATRIX(mat1, mat2, Row, Col, eps) \
45
do { for ( int i = 0; i < Row; i += 1 ) \
46
for ( int j = 0; j < Col; j += 1 ) \
47
EXPECT_NEAR((mat1)(i,j), (mat2)(i,j), eps) << "index = ("<< i<<","<<j<<")"; } while (0)
48
49
#define EXPECT_NEAR_STDVECTOR(vec1,vec2,eps) \
50
do { EXPECT_EQ((vec1).size(), (vec2).size()); \
51
EXPECT_NEAR_VECTOR(vec1, vec2, (vec1).size(), eps); } while (0)
52
53
#define EXPECT_NEAR_UTLVECTOR(vec1,vec2,eps) \
54
do { EXPECT_EQ((vec1).Size(), (vec2).Size()); \
55
EXPECT_NEAR_VECTOR(vec1, vec2, (vec1).Size(), eps); } while (0)
56
57
#define EXPECT_NEAR_VNLVECTOR(vec1,vec2,eps) EXPECT_NEAR_STDVECTOR(vec1,vec2,eps)
58
59
#define EXPECT_NEAR_VNLMATRIX(mat1,mat2,eps) \
60
do { EXPECT_EQ((mat1).rows(), (mat2).rows()); \
61
EXPECT_EQ((mat1).cols(), (mat2).cols()); \
62
EXPECT_NEAR_MATRIX(mat1, mat2, (mat1).rows(), (mat1).cols(), eps); } while (0)
63
64
#define EXPECT_NEAR_UTLMATRIX(mat1,mat2,eps) \
65
do { EXPECT_EQ((mat1).Rows(), (mat2).Rows()); \
66
EXPECT_EQ((mat1).Cols(), (mat2).Cols()); \
67
EXPECT_NEAR_MATRIX(mat1, mat2, (mat1).Rows(), (mat1).Cols(), eps); } while (0)
68
70
#endif
Generated by
1.8.11