Difference between revisions of "TUnit Assertions"
(New page: Assertions are defined by macros in the [http://tinyos.cvs.sourceforge.net→checkout: tinyos/tinyos-2.x-contrib/tunit/tos/lib/tunit/TestCase.h TestCase.h] file. You must <code>#include "T...) |
|||
Line 22: | Line 22: | ||
* '''<code>assertNotNull(<pointer>)</code>''': Fails if (pointer == NULL). Prints out the name of the pointer if it fails. | * '''<code>assertNotNull(<pointer>)</code>''': Fails if (pointer == NULL). Prints out the name of the pointer if it fails. | ||
+ | |||
+ | = See Also = | ||
+ | |||
+ | * [[TUnit]] | ||
+ | * [[Setting up TUnit]] |
Revision as of 08:01, 15 January 2008
Assertions are defined by macros in the TestCase.h file. You must #include "TestCase.h"
in your application to access assertions.
assertSuccess()
: The test automatically passes if execution reaches this point in the code.
assertFail("Fail Message")
: The test automatically fails if execution reaches this point in the code.
assertEquals("Fail Message", <expected>, <actual>)
: Fails if (expected != actual).
assertNotEquals("Fail Message", <not expected>, <actual>)
: Fails if (expected == actual).
assertResultIsBelow("Fail Message", <upperbound>, <actual>)
: Fails if (upperbound <= actual).
assertResultIsAbove("Fail Message", <lowerbound>, <actual>)
: Fails if (lowerbound >= actual)
assertCompares("Fail Message", <array1>, <array2>, size)
: Fails if the bytes in both arrays are not identical for the given size.
assertTrue("Fail Message", <condition>)
: Fails if (condition == FALSE).
assertFalse("Fail Message", <condition>)
: Fails if (condition == TRUE).
assertNull(<pointer>)
: Fails if (pointer != NULL). Prints out the name of the pointer if it fails.
assertNotNull(<pointer>)
: Fails if (pointer == NULL). Prints out the name of the pointer if it fails.