Difference between revisions of "TUnit Assertions"

From TinyOS Wiki
Jump to: navigation, search
(New page: Assertions are defined by macros in the [http://tinyos.cvs.sourceforge.netcheckout: tinyos/tinyos-2.x-contrib/tunit/tos/lib/tunit/TestCase.h TestCase.h] file. You must <code>#include "T...)
 
(See Also)
 
(One intermediate revision by the same user not shown)
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]]
 +
 +
= Next =
 +
 +
* [[Setting up TUnit]]

Latest revision as of 08:04, 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.

See Also

Next