pic24_unittest.h

Go to the documentation of this file.
00001 /*
00002  * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")"
00003  * All rights reserved.
00004  * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University)
00005  * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University)
00006  * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University)
00007  *
00008  * Permission to use, copy, modify, and distribute this software and its
00009  * documentation for any purpose, without fee, and without written agreement is
00010  * hereby granted, provided that the above copyright notice, the following
00011  * two paragraphs and the authors appear in all copies of this software.
00012  *
00013  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
00014  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
00015  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
00016  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00017  *
00018  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
00019  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
00020  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
00021  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
00022  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
00023  *
00024  * Please maintain this header in its entirety when copying/modifying
00025  * these files.
00026  *
00027  *
00028  */
00029 
00030 
00031 // Documentation for this file. If the \file tag isn't present,
00032 // this file won't be documented.
00039 #ifndef  _PIC24_UNITTEST_H_
00040 #define _PIC24_UNITTEST_H_
00041 
00042 // Circular includes: pic24_util needs this include, but
00043 // this needs reportError. Pre-declare here.
00044 void reportError(const char* message);
00045 
00049 #define TOSTRING(x) _TOSTRING(x)
00050 // A helper macro used by \ref TOSTRING.
00051 #define _TOSTRING(x) #x
00053 
00054 
00058 #define ERROR_FILE_LINE(msg) "Error in " __FILE__ " line " TOSTRING(__LINE__) ": " msg
00059 
00060 // Uncomment the following line to remove all the ASSERTs
00061 // from the program:
00062 //#define _NOASSERT
00063 #ifdef _NOASSERT
00064 #define ASSERT(placeholder) (void)0
00065 #define _COMPILE_ASSERT_SYMBOL_INNER(line, msg)
00066 #define _COMPILE_ASSERT_SYMBOL(line, msg)
00067 #define COMPILE_ASSERT(test, msg)
00068 #else
00069 
00079 #define COMPILE_ASSERT(test, msg)                      \
00080                 typedef char _COMPILE_ASSERT_SYMBOL(__LINE__, msg) [ ((test) ? 1 : -1) ]
00081 // A helper macro used by \ref COMPILE_ASSERT.
00082 #define _COMPILE_ASSERT_SYMBOL_INNER(line, msg) __COMPILE_ASSERT_ ## line ## _____ ## msg
00083 // A helper macro used by \ref COMPILE_ASSERT.
00084 #define _COMPILE_ASSERT_SYMBOL(line, msg) _COMPILE_ASSERT_SYMBOL_INNER(line, msg)
00085 
00093 #define ASSERT(test) picAssert(test, ERROR_FILE_LINE("ASSERT(" #test ") failed.\n"))
00094 
00104 static inline void picAssert(uint8 test, const char* message) {
00105   if (!test)
00106     reportError(message);
00107 }
00108 #endif
00109 
00110 #endif // #ifndef  _PIC24_UNITTEST_H_

Generated on Mon Oct 18 07:40:47 2010 for Python-on-a-chip by  doxygen 1.5.9