Documentation

Macros

All the public Macros in UnitKit

Macros

Default

UKDoesNotRaiseException( a)

Tests that the code piece raises no exception.

See also UKRaisesException() .

    UKFail()

    Reports a failure.

      UKFalse( condition)

      Tests that an expression is false.

        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( 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( a, b)

            Tests that two primitive integers are equal.

            a is the expected value and b the tested value.

              UKIntsNotEqual( a, b)

              Tests that two primitive integers are not equal.

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

                UKNil( ref)

                Tests that ref == nil.

                  UKNotNil( ref)

                  Tests that ref != nil.

                    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( a, b)

                      Tests that [a isEqual: b].

                      a is the expected value and b the tested value.

                        UKObjectsNotEqual( a, b)

                        Tests that ![a isEqual: b].

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

                          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( a, b)

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

                            a is the expected value and b the tested value.

                              UKPass()

                              Reports a success.

                                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( a, b)

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

                                  See NSException.

                                    UKRaisesExceptionNamed( a, b)

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

                                    See also -[NSException name] .

                                      UKStringContains( a, b)

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

                                        UKStringDoesNotContain( a, b)

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

                                          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( 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( condition)

                                              Tests that an expression is true.