TUnit Assertions

From TinyOS Wiki
Jump to: navigation, search

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