AJA NTV2 SDK
17.1.3.1410
NTV2 SDK 17.1.3.1410
ntv2bft.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: MIT */
10
#ifndef _NTV2BFT_H_
11
#define _NTV2BFT_H_
12
#if !defined(NTV2_DEPRECATE_17_0)
13
14
#include <iostream>
15
#include <assert.h>
16
17
#if defined (_DEBUG) && defined (MSWindows)
18
#include <Windows.h>
19
#endif
20
21
#define STDOUT std::cout
22
#define STDERR std::cerr
23
#define ENDL std::endl
24
25
#if defined (_DEBUG)
26
class
NTV2BFT_Debugger
27
{
28
public
:
29
static
inline
void
Stop (
void
)
30
{
31
#if defined (MSWindows)
32
DebugBreak ();
33
#else
34
// FORCE TRIGGER DEBUGGER
35
STDERR
<<
"Stop"
<<
ENDL
;
36
char
* pByte (
NULL
);
37
char
byte (*pByte);
38
byte
++;
39
#endif // not Windows
40
}
41
};
42
#define DEBUG_BREAK() do {NTV2BFT_Debugger::Stop ();} while (false)
43
#else
44
#define DEBUG_BREAK() do {} while (false)
45
#endif // _DEBUG
46
47
48
/**************************************************************************************************************************
49
Basic Functionality Testing Macros
50
51
These macros are useful for logging the results of basic functionality tests (BFTs).
52
They assume that the function in which they're used returns an boolean value, which will be true if successful,
53
and false if unsuccessful.
54
55
SHOULD_BE_TRUE (condition) -- Logs a failure if the condition evaluates to false; otherwise, logs a success.
56
Use this macro when you expect the condition expression to return true.
57
SHOULD_BE_FALSE (condition) -- Logs a failure if the condition evaluates to true; otherwise, logs a success.
58
Use this macro when you expect the condition expression to return false.
59
SHOULD_BE_EQUAL (x, y) -- Logs a success if x == y; otherwise logs a failure.
60
Use this macro when you expect x to equal y.
61
SHOULD_BE_UNEQUAL (x, y) -- Logs a success if x != y; otherwise logs a failure.
62
Use this macro when you expect x to not equal y.
63
64
The following two symbols determine how these macros behave.
65
66
SHOW_PASSED If true, successes are logged to STDOUT. (Failures are always logged to STDERR.)
67
If false, successes are not logged.
68
69
STOP_AFTER_FAILURE If true, failures will abort the rest of the test.
70
If false, failures won't stop execution, but will instead "press on regardless".
71
72
DEBUG_BREAK_AFTER_FAILURE If true, failures in _DEBUG builds will invoke the DEBUG_BREAK macro (see above).
73
If false, failures won't call DEBUG_BREAK in _DEBUG builds.
74
**************************************************************************************************************************/
75
#if !defined (SHOW_PASSED)
76
#define SHOW_PASSED (false)
77
#endif
78
#if !defined (STOP_AFTER_FAILURE)
79
#define STOP_AFTER_FAILURE (true)
80
#endif
81
#if !defined (DEBUG_BREAK_AFTER_FAILURE)
82
#define DEBUG_BREAK_AFTER_FAILURE (false)
83
#endif
84
85
86
#define SHOULD_BE_TRUE(_x_) do \
87
{ \
88
if (!(_x_)) \
89
{ \
90
STDERR << "## ERROR: '" << __FUNCTION__ << "' failed at line " << __LINE__ << " of " << __FILE__ << ":" << ENDL \
91
<< " Expected 'True' result from '" << #_x_ << "'" << ENDL \
92
<< " Instead got 'False'" << ENDL; \
93
if (STOP_AFTER_FAILURE) \
94
{ \
95
if (DEBUG_BREAK_AFTER_FAILURE) \
96
DEBUG_BREAK (); \
97
return false; \
98
} \
99
} \
100
else if (SHOW_PASSED) \
101
STDOUT << "## NOTE: '" << #_x_ << "' in '" << __FUNCTION__ << "' returned 'True'" << ENDL; \
102
} while (false)
103
104
105
#define SHOULD_BE_FALSE(_x_) do \
106
{ \
107
if (_x_) \
108
{ \
109
STDERR << "## ERROR: '" << __FUNCTION__ << "' failed at line " << __LINE__ << " of " << __FILE__ << ":" << ENDL \
110
<< " Expected 'False' result from '" << #_x_ << "'" << ENDL \
111
<< " Instead got 'True'" << ENDL; \
112
if (STOP_AFTER_FAILURE) \
113
{ \
114
if (DEBUG_BREAK_AFTER_FAILURE) \
115
DEBUG_BREAK (); \
116
return false; \
117
} \
118
} \
119
else if (SHOW_PASSED) \
120
STDOUT << "## NOTE: '" << #_x_ << "' in '" << __FUNCTION__ << "' returned 'False'" << ENDL; \
121
} while (false)
122
123
124
#define SHOULD_BE_NULL(_x_) do \
125
{ \
126
if ((_x_) != NULL) \
127
{ \
128
STDERR << "## ERROR: '" << __FUNCTION__ << "' failed at line " << __LINE__ << " of " << __FILE__ << ":" << ENDL \
129
<< " '" << (_x_) << "' is non-NULL" << ENDL \
130
<< " Expected '" << #_x_ << "' to be NULL" << ENDL; \
131
if (STOP_AFTER_FAILURE) \
132
{ \
133
if (DEBUG_BREAK_AFTER_FAILURE) \
134
DEBUG_BREAK (); \
135
return false; \
136
} \
137
} \
138
else if (SHOW_PASSED) \
139
STDOUT << "## NOTE: '" << #_x_ << "' is NULL in '" << __FUNCTION__ << "'" << ENDL; \
140
} while (false)
141
142
143
#define SHOULD_BE_NON_NULL(_x_) do \
144
{ \
145
if ((_x_) == NULL) \
146
{ \
147
STDERR << "## ERROR: '" << __FUNCTION__ << "' failed at line " << __LINE__ << " of " << __FILE__ << ":" << ENDL \
148
<< " '" << (_x_) << "' is NULL" << ENDL \
149
<< " Expected '" << #_x_ << "' to be non-NULL" << ENDL; \
150
if (STOP_AFTER_FAILURE) \
151
{ \
152
if (DEBUG_BREAK_AFTER_FAILURE) \
153
DEBUG_BREAK (); \
154
return false; \
155
} \
156
} \
157
else if (SHOW_PASSED) \
158
STDOUT << "## NOTE: '" << #_x_ << "' is non-NULL in '" << __FUNCTION__ << "'" << ENDL; \
159
} while (false)
160
161
162
#define SHOULD_BE_EQUAL(_x_, _y_) do \
163
{ \
164
if ((_x_) != (_y_)) \
165
{ \
166
STDERR << "## ERROR: '" << __FUNCTION__ << "' failed at line " << __LINE__ << " of " << __FILE__ << ":" << ENDL \
167
<< " '" << (_x_) << "' is not equal to '" << (_y_) << "'" << ENDL \
168
<< " Expected '" << #_x_ << "' to equal '" << #_y_ << "'" << ENDL; \
169
if (STOP_AFTER_FAILURE) \
170
{ \
171
if (DEBUG_BREAK_AFTER_FAILURE) \
172
DEBUG_BREAK (); \
173
return false; \
174
} \
175
} \
176
else if (SHOW_PASSED) \
177
STDOUT << "## NOTE: '" << #_x_ << "' is equal to '" << #_y_ << "' in '" << __FUNCTION__ << "'" << ENDL; \
178
} while (false)
179
180
181
#define SHOULD_BE_UNEQUAL(_x_, _y_) do \
182
{ \
183
if ((_x_) == (_y_)) \
184
{ \
185
STDERR << "## ERROR: '" << __FUNCTION__ << "' failed at line " << __LINE__ << " of " << __FILE__ << ":" << ENDL \
186
<< " '" << (_x_) << "' is equal to '" << (_y_) << "'" << ENDL \
187
<< " Expected '" << #_x_ << "' to not equal '" << #_y_ << "'" << ENDL; \
188
if (STOP_AFTER_FAILURE) \
189
{ \
190
if (DEBUG_BREAK_AFTER_FAILURE) \
191
DEBUG_BREAK (); \
192
return false; \
193
} \
194
} \
195
else if (SHOW_PASSED) \
196
STDOUT << "## NOTE: '" << #_x_ << "' is not equal to '" << #_y_ << "' in '" << __FUNCTION__ << "'" << ENDL; \
197
} while (false)
198
199
#endif // !defined(NTV2_DEPRECATE_17_0)
200
#endif // _NTV2BFT_H_
NULL
#define NULL
Definition:
ntv2caption608types.h:19
ENDL
#define ENDL
Definition:
ntv2bft.h:23
STDERR
#define STDERR
Definition:
ntv2bft.h:22
libajantv2
ajantv2
includes
ntv2bft.h
Generated on Tue Dec 3 2024 10:25:59 for AJA NTV2 SDK by
1.8.17