UKTest documentation

Authors

Generated by builder

Copyright: (C) 2004 James Duncan Davidson, Michael Milvich, Nicolas Roard


Contents -

  1. Software documentation for the UKTest protocol
  2. UKTest macros

Software documentation for the UKTest protocol

UKTest

Declared in:
UKTest.h

@abstract The protocol that marks a class as a test class.

All classes that conforms to UKTest, including their subclasses, are picked up by UKRunner.

If a filtering option such as -c is passed to ukrun, this can prevent the a test class to be picked up.

UKTest macros

UKDoesNotRaiseException

UKDoesNotRaiseException(a)

Tests that the code piece raises no exception.

See also UKRaisesException() .


UKFail

UKFail

Reports a failure.


UKFalse

UKFalse(condition)

Tests that an expression is false.


UKFloatsEqual

UKFloatsEqual(a, b, d)

Tests that two primitive floats are equal or almost, this evaluates whether fabs(a - b) <= d is true.

d is the error margin.

a is the expected value and b the tested value.


UKFloatsNotEqual

UKFloatsNotEqual(a, b, d)

Tests that two primitive floats are not equal, this evaluates whether fabs(a - b) > d is true.

d is the error margin.

a is the non-expected value and b the tested value.


UKIntsEqual

UKIntsEqual(a, b)

Tests that two primitive integers are equal.

a is the expected value and b the tested value.


UKIntsNotEqual

UKIntsNotEqual(a, b)

Tests that two primitive integers are not equal.

a is the non-expected value and b the tested value.


UKNil

UKNil(ref)

Tests that ref == nil.


UKNotNil

UKNotNil(ref)

Tests that ref != nil.


UKObjectKindOf

UKObjectKindOf(a, b)

Tests macro that a is a subclass of b, this uses -[NSObject isKindOfClass:] behind the scene.

Most of the time UKObjectsEqual([a class], [b class]) would be similar, but not always (i.e. NSCFArray/NSArray on Mac OS X). Example:

 UKObjectKindOf(myObject, NSArray)
 

UKObjectsEqual

UKObjectsEqual(a, b)

Tests that [a isEqual: b].

a is the expected value and b the tested value.


UKObjectsNotEqual

UKObjectsNotEqual(a, b)

Tests that ![a isEqual: b].

a is the non-expected value and b the tested value.


UKObjectsNotSame

UKObjectsNotSame(a, b)

Tests that the objects are not identical with a != b.

a is the non-expected value and b the tested value.


UKObjectsSame

UKObjectsSame(a, b)

Tests that the objects are identical with a == b.

a is the expected value and b the tested value.


UKPass

UKPass

Reports a success.


UKRaisesException

UKRaisesException(a)

Tests that the code piece raises an exception.

The exception testing macros get a bit more involved than all the other ones we have here because of the need for embedding the try-catch in the generated code. In addition, the statements are wrapped in a do{...}while( NO) block so that the generated code is sane even if the macro appears in a context like:

 if (someFlag)
    UKRaisesException(someExpression)
 else
    UKRaisesException(someOtherExpression)

UKRaisesExceptionClass

UKRaisesExceptionClass(a, b)

Tests that the code piece raises an exception of the class name b.

See NSException.


UKRaisesExceptionNamed

UKRaisesExceptionNamed(a, b)

Tests that the code piece raises an exception of the name b.

See also -[NSException name].


UKStringContains

UKStringContains(a, b)

Tests that b is a substring of a, this uses -[NSString rangeOfString:].


UKStringDoesNotContain

UKStringDoesNotContain(a, b)

Tests that b is not a substring of a, this uses -[NSString rangeOfString:].


UKStringsEqual

UKStringsEqual(a, b)

Tests that [a isEqual: b].

a is the expected value and b the tested value.

This is the same than UKObjectsEqual() , this just helps readibility a bit, since testing string equality is pretty common.


UKStringsNotEqual

UKStringsNotEqual(a, b)

Tests that ![a isEqual: b].

a is the non-expected value and b the tested value.

This is the same than UKObjectsNotEqual() , this just helps readibility a bit, since testing string equality is pretty common.


UKTrue

UKTrue(condition)

Tests that an expression is true.