ObjFW
Loading...
Searching...
No Matches
Macros
OTAssert.h File Reference

Go to the source code of this file.

Macros

#define OTAssert(condition, ...)
 Asserts that the specified condition condition holds.
 
#define OTAssertTrue(condition, ...)    OTAssert(condition == true, ## __VA_ARGS__)
 Asserts that the specified condition is true.
 
#define OTAssertFalse(condition, ...)    OTAssert(condition == false, ## __VA_ARGS__)
 Asserts that the specified condition is false.
 
#define OTAssertEqual(a, b, ...)   OTAssert(a == b, ## __VA_ARGS__)
 Asserts that the two values are equal.
 
#define OTAssertNotEqual(a, b, ...)   OTAssert(a != b, ## __VA_ARGS__)
 Asserts that the two values are not equal.
 
#define OTAssertLessThan(a, b, ...)   OTAssert(a < b, ## __VA_ARGS__)
 Asserts that the value is less than another value.
 
#define OTAssertLessThanOrEqual(a, b, ...)   OTAssert(a <= b, ## __VA_ARGS__)
 Asserts that the value is less than or equal to another value.
 
#define OTAssertGreaterThan(a, b, ...)   OTAssert(a > b, ## __VA_ARGS__)
 Asserts that the value is greater than another value.
 
#define OTAssertGreaterThanOrEqual(a, b, ...)   OTAssert(a >= b, ## __VA_ARGS__)
 Asserts that the value is greater than or equal to another value.
 
#define OTAssertEqualObjects(a, b, ...)   OTAssert([a isEqual: b], ## __VA_ARGS__)
 Asserts that the two objects are equal.
 
#define OTAssertNotEqualObjects(a, b, ...)    OTAssert(![a isEqual: b], ## __VA_ARGS__)
 Asserts that the two objects are not equal.
 
#define OTAssertNil(object, ...)   OTAssert(object == nil, ## __VA_ARGS__)
 Asserts that the specified object is nil.
 
#define OTAssertNotNil(object, ...)   OTAssert(object != nil, ## __VA_ARGS__)
 Asserts that the specified object is not nil.
 
#define OTAssertThrows(expression, ...)
 Asserts that the specified expression throws an exception.
 
#define OTAssertThrowsSpecific(expression, exception, ...)
 Asserts that the specified expression throws a specific exception.
 
#define OTSkip(...)    OTSkipImpl(self, _cmd, @__FILE__, __LINE__, ## __VA_ARGS__, nil)
 Skips the current test, making it neither fail nor succeeed.
 

Macro Definition Documentation

◆ OTAssert

#define OTAssert ( condition,
... )
Value:
OTAssertImpl(self, _cmd, condition, @#condition, \
@__FILE__, __LINE__, ## __VA_ARGS__, nil)
#define nil
A value representing no object.
Definition ObjFWRT.h:68

Asserts that the specified condition condition holds.

Parameters
conditionThe condition to check
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertEqual

#define OTAssertEqual ( a,
b,
... )   OTAssert(a == b, ## __VA_ARGS__)

Asserts that the two values are equal.

Parameters
aThe value to check
bThe expected value
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertEqualObjects

#define OTAssertEqualObjects ( a,
b,
... )   OTAssert([a isEqual: b], ## __VA_ARGS__)

Asserts that the two objects are equal.

Parameters
aThe object to check
bThe object a is expected to be equal to
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertFalse

#define OTAssertFalse ( condition,
... )    OTAssert(condition == false, ## __VA_ARGS__)

Asserts that the specified condition is false.

Parameters
conditionThe condition to check
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertGreaterThan

#define OTAssertGreaterThan ( a,
b,
... )   OTAssert(a > b, ## __VA_ARGS__)

Asserts that the value is greater than another value.

Parameters
aThe value to check
bThe value a should be greater than
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertGreaterThanOrEqual

#define OTAssertGreaterThanOrEqual ( a,
b,
... )   OTAssert(a >= b, ## __VA_ARGS__)

Asserts that the value is greater than or equal to another value.

Parameters
aThe value to check
bThe value a should be greater than or equal to
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertLessThan

#define OTAssertLessThan ( a,
b,
... )   OTAssert(a < b, ## __VA_ARGS__)

Asserts that the value is less than another value.

Parameters
aThe value to check
bThe value a should be less than
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertLessThanOrEqual

#define OTAssertLessThanOrEqual ( a,
b,
... )   OTAssert(a <= b, ## __VA_ARGS__)

Asserts that the value is less than or equal to another value.

Parameters
aThe value to check
bThe value a should be less than or equal to
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertNil

#define OTAssertNil ( object,
... )   OTAssert(object == nil, ## __VA_ARGS__)

Asserts that the specified object is nil.

Parameters
objectThe object to should be nil
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertNotEqual

#define OTAssertNotEqual ( a,
b,
... )   OTAssert(a != b, ## __VA_ARGS__)

Asserts that the two values are not equal.

Parameters
aThe value to check
bThe value a should not have
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertNotEqualObjects

#define OTAssertNotEqualObjects ( a,
b,
... )    OTAssert(![a isEqual: b], ## __VA_ARGS__)

Asserts that the two objects are not equal.

Parameters
aThe object to check
bThe object a is expected to be not equal to
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertNotNil

#define OTAssertNotNil ( object,
... )   OTAssert(object != nil, ## __VA_ARGS__)

Asserts that the specified object is not nil.

Parameters
objectThe object to should not be nil
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertThrows

#define OTAssertThrows ( expression,
... )
Value:
{ \
bool OTThrown = false; \
@try { \
expression; \
} @catch (id e) { \
OTThrown = true; \
} \
OTAssert(OTThrown, ## __VA_ARGS__); \
}

Asserts that the specified expression throws an exception.

Parameters
expressionThe expression that should throw
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertThrowsSpecific

#define OTAssertThrowsSpecific ( expression,
exception,
... )
Value:
{ \
bool OTThrown = false; \
@try { \
expression; \
} @catch (exception *e) { \
OTThrown = true; \
} \
OTAssert(OTThrown, ## __VA_ARGS__); \
}

Asserts that the specified expression throws a specific exception.

Parameters
expressionThe expression that should throw
exceptionThe exception the expression should throw (as just the class name, without quotes)
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTAssertTrue

#define OTAssertTrue ( condition,
... )    OTAssert(condition == true, ## __VA_ARGS__)

Asserts that the specified condition is true.

Parameters
conditionThe condition to check
...An optional format string to print if the assertion failed, followed by optional arguments

◆ OTSkip

#define OTSkip ( ...)     OTSkipImpl(self, _cmd, @__FILE__, __LINE__, ## __VA_ARGS__, nil)

Skips the current test, making it neither fail nor succeeed.

Parameters
...An optional format string to print why the test was skipped, followed by optional arguments