ObjFW
Loading...
Searching...
No Matches
src
test
OTAssert.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3
*
4
* All rights reserved.
5
*
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU Lesser General Public License version 3.0 only,
8
* as published by the Free Software Foundation.
9
*
10
* This program is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13
* version 3.0 for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public License
16
* version 3.0 along with this program. If not, see
17
* <https://www.gnu.org/licenses/>.
18
*/
19
20
/*
21
* Unfortunately, that's the only way to make all compilers happy with the GNU
22
* extensions for variadic macros that are being used here.
23
*/
24
#pragma GCC system_header
25
35
#define OTAssert(condition, ...) \
36
_OTAssertImpl(self, _cmd, condition, @#condition, \
37
@__FILE__, __LINE__, ## __VA_ARGS__, nil)
38
46
#define OTAssertTrue(condition, ...) \
47
OTAssert((condition) == true, ## __VA_ARGS__)
48
56
#define OTAssertFalse(condition, ...) \
57
OTAssert((condition) == false, ## __VA_ARGS__)
58
67
#define OTAssertEqual(a, b, ...) OTAssert(a == b, ## __VA_ARGS__)
68
77
#define OTAssertNotEqual(a, b, ...) OTAssert(a != b, ## __VA_ARGS__)
78
87
#define OTAssertLessThan(a, b, ...) OTAssert(a < b, ## __VA_ARGS__)
88
97
#define OTAssertLessThanOrEqual(a, b, ...) OTAssert(a <= b, ## __VA_ARGS__)
98
107
#define OTAssertGreaterThan(a, b, ...) OTAssert(a > b, ## __VA_ARGS__)
108
117
#define OTAssertGreaterThanOrEqual(a, b, ...) OTAssert(a >= b, ## __VA_ARGS__)
118
127
#define OTAssertEqualObjects(a, b, ...) OTAssert([a isEqual: b], ## __VA_ARGS__)
128
137
#define OTAssertNotEqualObjects(a, b, ...) \
138
OTAssert(![a isEqual: b], ## __VA_ARGS__)
139
147
#define OTAssertNil(object, ...) OTAssert(object == nil, ## __VA_ARGS__)
148
156
#define OTAssertNotNil(object, ...) OTAssert(object != nil, ## __VA_ARGS__)
157
165
#define OTAssertThrows(expression, ...) \
166
{ \
167
bool OTThrown = false; \
168
@try { \
169
expression; \
170
} @catch (id e) { \
171
OTThrown = true; \
172
} \
173
OTAssert(OTThrown, ## __VA_ARGS__); \
174
}
175
185
#define OTAssertThrowsSpecific(expression, exception, ...) \
186
{ \
187
bool OTThrown = false; \
188
@try { \
189
expression; \
190
} @catch (exception *e) { \
191
OTThrown = true; \
192
} \
193
OTAssert(OTThrown, ## __VA_ARGS__); \
194
}
195
202
#define OTSkip(...) \
203
_OTSkipImpl(self, _cmd, @__FILE__, __LINE__, ## __VA_ARGS__, nil)
204
205
#ifdef __cplusplus
206
extern
"C"
{
207
#endif
208
extern
void
_OTAssertImpl(
id
testCase,
SEL
test,
bool
condition,
209
OFString
*check,
OFString
*file,
size_t
line, ...);
210
extern
void
_OTSkipImpl(
id
testCase,
SEL
test,
OFString
*file,
size_t
line,
211
...);
212
#ifdef __cplusplus
213
}
214
#endif
OFString
A class for handling strings.
Definition
OFString.h:143
Generated by
1.12.0