ObjFW
Loading...
Searching...
No Matches
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, ...)
 Asserts that the specified condition is true.
 
#define OTAssertFalse(condition, ...)
 Asserts that the specified condition is false.
 
#define OTAssertEqual(a, b, ...)
 Asserts that the two values are equal.
 
#define OTAssertNotEqual(a, b, ...)
 Asserts that the two values are not equal.
 
#define OTAssertLessThan(a, b, ...)
 Asserts that the value is less than another value.
 
#define OTAssertLessThanOrEqual(a, b, ...)
 Asserts that the value is less than or equal to another value.
 
#define OTAssertGreaterThan(a, b, ...)
 Asserts that the value is greater than another value.
 
#define OTAssertGreaterThanOrEqual(a, b, ...)
 Asserts that the value is greater than or equal to another value.
 
#define OTAssertEqualObjects(a, b, ...)
 Asserts that the two objects are equal.
 
#define OTAssertNotEqualObjects(a, b, ...)
 Asserts that the two objects are not equal.
 
#define OTAssertNil(object, ...)
 Asserts that the specified object is nil.
 
#define OTAssertNotNil(object, ...)
 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(...)
 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,
... )
Value:
OTAssert(a == b, ## __VA_ARGS__)
#define OTAssert(condition,...)
Asserts that the specified condition condition holds.
Definition OTAssert.h:35

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,
... )
Value:
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,
... )
Value:
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,
... )
Value:
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,
... )
Value:
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,
... )
Value:
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,
... )
Value:
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,
... )
Value:
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,
... )
Value:
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,
... )
Value:
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,
... )
Value:
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,
... )
Value:
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 ( ...)
Value:
_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