include/pic24_unittest.h File Reference

Go to the source code of this file.

Defines

#define ERROR_FILE_LINE(msg)   "Error in " __FILE__ " line " TOSTRING(__LINE__) ": " msg
#define ASSERT(test)   picAssert(test, ERROR_FILE_LINE("ASSERT(" #test ") failed.\n"))
Macros to convert a number to a string
Typical usage: TOSTRING(__LINE__)

#define TOSTRING(x)   _TOSTRING(x)
#define _TOSTRING(x)   #x

Functions

void reportError (const char *message)
static void picAssert (uint8 test, const char *message)


Detailed Description

Extremely simple unit testing framework, inspired by http://www.jera.com/techinfo/jtns/jtn002.html.

Definition in file pic24_unittest.h.


Define Documentation

#define ASSERT ( test   )     picAssert(test, ERROR_FILE_LINE("ASSERT(" #test ") failed.\n"))

Assert that test is true. See picAssert for details. NOTE: only test results; DO NOT include main-line code in an ASSSERT, since it can be compiled out. For example, ASSERT(myFunc()) is dangerous, since myFunc() will no longer be called if ASSERTL is disabled by defining _NDEBUG.

Definition at line 89 of file pic24_unittest.h.

#define ERROR_FILE_LINE ( msg   )     "Error in " __FILE__ " line " TOSTRING(__LINE__) ": " msg

A macro to add the file name and line at which the macro was called to the given message.

Parameters:
msg Message to add file/line info to.

Definition at line 57 of file pic24_unittest.h.


Function Documentation

static void picAssert ( uint8  test,
const char *  message 
) [inline, static]

A function to reset the chip and report a message if the test is false. Assumes reportError is called at start-up to report any assertion violations.

Parameters:
test Boolean results of test run. If false, reset and print message.
message Message to print if assertion fails.

Definition at line 100 of file pic24_unittest.h.

void reportError ( const char *  sz_errorMessage  ) 

Report a critical error by recording a message in sz_lastError then resetting the chip, assuming hat printResetCause will be called during chip initialization.

Parameters:
sz_errorMessage Error message to report.
See also:
REPORT_ERROR

Definition at line 141 of file pic24_util.c.


Generated on Sun Mar 15 11:14:22 2009 for PIC24 Support Libraries by  doxygen 1.5.8