TUnit Assertions

From TinyOS Wiki
Revision as of 14:07, 21 December 2007 by Dmoss (talk | contribs) (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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.