Slicer
4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Libs
vtkAddon
vtkAddonTestingMacros.h
Go to the documentation of this file.
1
/*==============================================================================
2
3
Program: 3D Slicer
4
5
Copyright (c) Kitware Inc.
6
7
See COPYRIGHT.txt
8
or http://www.slicer.org/copyright/copyright.txt for details.
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
16
This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
17
and was partially funded by NIH grant 1U24CA194354-01
18
19
==============================================================================*/
20
21
#ifndef __vtkAddonTestingMacros_h
22
#define __vtkAddonTestingMacros_h
23
24
// vtkAddon includes
25
#include <
vtkAddonTestingUtilities.h
>
26
51
53
#define CHECK_NULL(pointer) \
54
{ \
55
const void* pointerValue = (pointer); \
56
if (!vtkAddonTestingUtilities::CheckNull(__LINE__,#pointer " is not NULL", pointerValue)) \
57
{ \
58
return EXIT_FAILURE; \
59
} \
60
}
61
63
#define CHECK_NOT_NULL(pointer) \
64
{ \
65
if (!vtkAddonTestingUtilities::CheckNotNull(__LINE__,#pointer " is NULL", (pointer))) \
66
{ \
67
return EXIT_FAILURE; \
68
} \
69
}
70
73
#define CHECK_NOT_NULL_ADD_REPORT(pointer, methodToCallOnFailure) \
74
{ \
75
if (!vtkAddonTestingUtilities::CheckNotNull(__LINE__,#pointer " is NULL", (pointer))) \
76
{ \
77
methodToCallOnFailure; \
78
return EXIT_FAILURE; \
79
} \
80
}
81
82
#define CHECK_EXIT_SUCCESS(actual) \
83
{ \
84
if (!vtkAddonTestingUtilities::CheckInt(__LINE__,#actual " != EXIT_SUCCESS", (actual), EXIT_SUCCESS)) \
85
{ \
86
return EXIT_FAILURE; \
87
} \
88
}
89
91
#define CHECK_DOUBLE(actual, expected) \
92
{ \
93
if (!vtkAddonTestingUtilities::Check<double>(__LINE__,#actual " != " #expected, (actual), (expected), "CheckDouble")) \
94
{ \
95
return EXIT_FAILURE; \
96
} \
97
}
98
100
#define CHECK_DOUBLE_TOLERANCE(actual, expected, tolerance) \
101
{ \
102
if (!vtkAddonTestingUtilities::CheckDoubleTolerance(__LINE__,#actual " != " #expected " (tolerance: " #tolerance ")", (actual), (expected), (tolerance))) \
103
{ \
104
return EXIT_FAILURE; \
105
} \
106
}
107
109
#define CHECK_INT(actual, expected) \
110
{ \
111
if (!vtkAddonTestingUtilities::CheckInt(__LINE__,#actual " != " #expected, (actual), (expected))) \
112
{ \
113
return EXIT_FAILURE; \
114
} \
115
}
116
119
#define CHECK_INT_ADD_REPORT(actual, expected, methodToCallOnFailure) \
120
{ \
121
if (!vtkAddonTestingUtilities::CheckInt(__LINE__,#actual " != " #expected, (actual), (expected))) \
122
{ \
123
methodToCallOnFailure; \
124
return EXIT_FAILURE; \
125
} \
126
}
127
129
#define CHECK_POINTER(actual, expected) \
130
{ \
131
if (!vtkAddonTestingUtilities::CheckPointer(__LINE__,#actual " != " #expected, (actual), (expected))) \
132
{ \
133
return EXIT_FAILURE; \
134
} \
135
}
136
138
#define CHECK_POINTER_DIFFERENT(actual, expected) \
139
{ \
140
if (!vtkAddonTestingUtilities::CheckPointer(__LINE__,#actual " == " #expected, (actual), (expected), false)) \
141
{ \
142
return EXIT_FAILURE; \
143
} \
144
}
145
147
#define CHECK_BOOL(actual, expected) \
148
{ \
149
if (!vtkAddonTestingUtilities::CheckInt(__LINE__,#actual " != " #expected, (actual)?1:0, (expected)?1:0)) \
150
{ \
151
return EXIT_FAILURE; \
152
} \
153
}
154
157
#define CHECK_STRING(actual, expected) \
158
{ \
159
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, (actual), (expected))) \
160
{ \
161
return EXIT_FAILURE; \
162
} \
163
}
164
168
#define CHECK_STD_STRING(actual, expected) \
169
{ \
170
std::string a = (actual); \
171
std::string e = (expected); \
172
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, a.c_str(), e.c_str())) \
173
{ \
174
return EXIT_FAILURE; \
175
} \
176
}
177
181
#define CHECK_STRING_ADD_REPORT(actual, expected, methodToCallOnFailure) \
182
{ \
183
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, (actual), (expected))) \
184
{ \
185
methodToCallOnFailure; \
186
return EXIT_FAILURE; \
187
} \
188
}
189
192
#define CHECK_STRING_DIFFERENT(actual, expected) \
193
{ \
194
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, (actual), (expected), false)) \
195
{ \
196
return EXIT_FAILURE; \
197
} \
198
}
199
203
#define CHECK_STD_STRING_DIFFERENT(actual, expected) \
204
{ \
205
std::string a = (actual); \
206
std::string e = (expected); \
207
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, a.c_str(), e.c_str(), false)) \
208
{ \
209
return EXIT_FAILURE; \
210
} \
211
}
212
213
// Commonly used headers in tests
214
#include "vtkNew.h"
215
#include "
vtkTestingOutputWindow.h
"
216
217
#endif
vtkTestingOutputWindow.h
vtkAddonTestingUtilities.h
Generated on Wed Dec 20 2017 04:49:08 for Slicer by
1.8.13