ITK
4.8.0
Insight Segmentation and Registration Toolkit
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
ITK
Modules
Core
TestKernel
include
itkTestingMacros.h
Go to the documentation of this file.
1
/*=========================================================================
2
*
3
* Copyright Insight Software Consortium
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0.txt
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*=========================================================================*/
18
#ifndef itkTestingMacros_h
19
#define itkTestingMacros_h
20
21
22
// object's Class must be specified to build on sun studio
23
#define EXERCISE_BASIC_OBJECT_METHODS( object, Class ) \
24
object->Print( std::cout ); \
25
std::cout << "Name of Class = " << object->GetNameOfClass() << std::endl; \
26
std::cout << "Name of Superclass = " << object->Class::Superclass::GetNameOfClass() << std::endl;
27
28
29
#define TRY_EXPECT_EXCEPTION( command ) \
30
try \
31
{ \
32
std::cout << "Trying " << #command << std::endl; \
33
command; \
34
std::cerr << "Failed to catch expected exception" << std::endl; \
35
std::cerr << " In " __FILE__ ", line " << __LINE__ << std::endl;\
36
return EXIT_FAILURE; \
37
} \
38
catch( itk::ExceptionObject & excp ) \
39
{ \
40
std::cout << "Caught expected exception" << std::endl; \
41
std::cout << excp << std::endl; \
42
}
43
44
45
#define TRY_EXPECT_NO_EXCEPTION( command ) \
46
try \
47
{ \
48
std::cout << "Trying " << #command << std::endl; \
49
command; \
50
} \
51
catch( itk::ExceptionObject & excp ) \
52
{ \
53
std::cerr << excp << std::endl; \
54
std::cerr << " In " __FILE__ ", line " << __LINE__ << std::endl; \
55
return EXIT_FAILURE; \
56
}
57
58
#define TEST_EXPECT_TRUE( command ) \
59
{ \
60
bool _TEST_EXPECT_TRUE_command(command); \
61
if( !(_TEST_EXPECT_TRUE_command) ) \
62
{ \
63
std::cerr << "Error in " << #command << std::endl; \
64
std::cerr << " In " __FILE__ ", line " << __LINE__ << std::endl; \
65
std::cerr << "Expected true" << std::endl; \
66
std::cerr << " but got " << _TEST_EXPECT_TRUE_command << std::endl; \
67
return EXIT_FAILURE; \
68
} \
69
}
70
71
#define TEST_EXPECT_EQUAL( lh, rh ) \
72
{ \
73
bool _TEST_EXPECT_EQUAL_result((lh) == (rh)); \
74
if( !(_TEST_EXPECT_EQUAL_result) ) \
75
{ \
76
std::cerr << "Error in " << #lh << " == " << #rh << std::endl; \
77
std::cerr << "\tIn " __FILE__ ", line " << __LINE__ << std::endl; \
78
std::cerr << "\tlh: " << (lh) << std::endl; \
79
std::cerr << "\trh: " << (rh) << std::endl; \
80
std::cerr << "Expression is not equal" << std::endl; \
81
return EXIT_FAILURE; \
82
} \
83
}
84
85
86
#define TEST_SET_GET( variable, command ) \
87
if( variable.GetPointer() != command ) \
88
{ \
89
std::cerr << "Error in " << #command << std::endl; \
90
std::cerr << " In " __FILE__ ", line " << __LINE__ << std::endl; \
91
std::cerr << "Expected " << variable.GetPointer() << std::endl; \
92
std::cerr << "but got " << command << std::endl; \
93
return EXIT_FAILURE; \
94
}
95
96
97
#define TEST_SET_GET_VALUE( variable, command ) \
98
if( variable != command ) \
99
{ \
100
std::cerr << "Error in " << #command << std::endl; \
101
std::cerr << " In " __FILE__ ", line " << __LINE__ << std::endl; \
102
std::cerr << "Expected " << variable << std::endl; \
103
std::cerr << "but got " << command << std::endl; \
104
return EXIT_FAILURE; \
105
}
106
107
#define TEST_SET_GET_NULL_VALUE( command ) \
108
if( ITK_NULLPTR != command ) \
109
{ \
110
std::cerr << "Error in " << #command << std::endl; \
111
std::cerr << " In " __FILE__ ", line " << __LINE__ << std::endl; \
112
std::cerr << "Expected " << "ITK_NULLPTR" << std::endl; \
113
std::cerr << "but got " << command << std::endl; \
114
return EXIT_FAILURE; \
115
}
116
117
118
#endif
Generated on Fri Jul 3 2015 03:56:41 for ITK by
1.8.5