00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ACEUNITASSERT_H
00029
00030 #define ACEUNITASSERT_H 1
00031
00032 #include "AceUnit.h"
00033
00039 #ifdef ACEUNIT_EXPLICIT_MESSAGES
00040 #include <stdio.h>
00041 #endif
00042
00046 #define fail(message) newAssertionError(message)
00047
00053 #define assertTrue(message, condition) do { if (!(condition)) { fail(message); } } while (false)
00054
00060 #define assertFalse(message, condition) do { if (condition) { fail(message); } } while (false)
00061
00071 #ifdef ACEUNIT_EXPLICIT_MESSAGES
00072 #define assertEquals(message, expected, actual) \
00073 do { \
00074 int32_t lexpected = (expected); \
00075 int32_t lactual = (actual); \
00076 if (lexpected != lactual) { \
00077 snprintf(runnerData->explicitMsgBuf, ACEUNIT_EXPLICIT_MSG_BUF_SIZE, "%s (expected: %d, actual: %d)", message, lexpected, lactual); \
00078 fail(runnerData->explicitMsgBuf); \
00079 } \
00080 } while (false)
00081 #else
00082 #define assertEquals(message, expected, actual) do { if (!((expected) == (actual))) { fail(message); } } while (false)
00083 #endif
00084
00094 #ifdef ACEUNIT_EXPLICIT_MESSAGES
00095 #define assertNotEquals(message, unexpected, actual) \
00096 do { \
00097 int32_t lunexpected = unexpected; \
00098 int32_t lactual = actual; \
00099 if (lunexpected == lactual) { \
00100 snprintf(runnerData->explicitMsgBuf, ACEUNIT_EXPLICIT_MSG_BUF_SIZE, "%s (unexpected: %d, actual: %d)", message, lunexpected, lactual); \
00101 fail(runnerData->explicitMsgBuf); \
00102 } \
00103 } while (false)
00104 #else
00105 #define assertNotEquals(message, unexpected, actual) do { if ((unexpected) == (actual)) { fail(message); } } while (false)
00106 #endif
00107
00113 #define assertNotNull(message, ptr) do { if (NULL == (ptr)) { fail(message); } } while (false)
00114
00120 #define assertNull(message, ptr) do { if (NULL != (ptr)) { fail(message); } } while (false)
00121
00122 #endif