34 #ifndef D_TestHarness_c_h 35 #define D_TestHarness_c_h 37 #include "CppUTestConfig.h" 39 #define CHECK_EQUAL_C_BOOL(expected,actual) \ 40 CHECK_EQUAL_C_BOOL_LOCATION(expected,actual,__FILE__,__LINE__) 42 #define CHECK_EQUAL_C_INT(expected,actual) \ 43 CHECK_EQUAL_C_INT_LOCATION(expected,actual,__FILE__,__LINE__) 45 #define CHECK_EQUAL_C_UINT(expected,actual) \ 46 CHECK_EQUAL_C_UINT_LOCATION(expected,actual,__FILE__,__LINE__) 48 #define CHECK_EQUAL_C_LONG(expected,actual) \ 49 CHECK_EQUAL_C_LONG_LOCATION(expected,actual,__FILE__,__LINE__) 51 #define CHECK_EQUAL_C_ULONG(expected,actual) \ 52 CHECK_EQUAL_C_ULONG_LOCATION(expected,actual,__FILE__,__LINE__) 54 #define CHECK_EQUAL_C_LONGLONG(expected,actual) \ 55 CHECK_EQUAL_C_LONGLONG_LOCATION(expected,actual,__FILE__,__LINE__) 57 #define CHECK_EQUAL_C_ULONGLONG(expected,actual) \ 58 CHECK_EQUAL_C_ULONGLONG_LOCATION(expected,actual,__FILE__,__LINE__) 60 #define CHECK_EQUAL_C_REAL(expected,actual,threshold) \ 61 CHECK_EQUAL_C_REAL_LOCATION(expected,actual,threshold,__FILE__,__LINE__) 63 #define CHECK_EQUAL_C_CHAR(expected,actual) \ 64 CHECK_EQUAL_C_CHAR_LOCATION(expected,actual,__FILE__,__LINE__) 66 #define CHECK_EQUAL_C_UBYTE(expected,actual) \ 67 CHECK_EQUAL_C_UBYTE_LOCATION(expected,actual,__FILE__,__LINE__) 69 #define CHECK_EQUAL_C_SBYTE(expected,actual) \ 70 CHECK_EQUAL_C_SBYTE_LOCATION(expected,actual,__FILE__,__LINE__) 72 #define CHECK_EQUAL_C_STRING(expected,actual) \ 73 CHECK_EQUAL_C_STRING_LOCATION(expected,actual,__FILE__,__LINE__) 75 #define CHECK_EQUAL_C_POINTER(expected,actual) \ 76 CHECK_EQUAL_C_POINTER_LOCATION(expected,actual,__FILE__,__LINE__) 78 #define CHECK_EQUAL_C_BITS(expected, actual, mask)\ 79 CHECK_EQUAL_C_BITS_LOCATION(expected, actual, mask, sizeof(actual), __FILE__, __LINE__) 81 #define FAIL_TEXT_C(text) \ 82 FAIL_TEXT_C_LOCATION(text,__FILE__,__LINE__) 85 FAIL_C_LOCATION(__FILE__,__LINE__) 87 #define CHECK_C(condition) \ 88 CHECK_C_LOCATION(condition, #condition, __FILE__,__LINE__) 98 #define TEST_GROUP_C_SETUP(group_name) \ 99 extern void group_##group_name##_setup_wrapper_c(void); \ 100 void group_##group_name##_setup_wrapper_c() 102 #define TEST_GROUP_C_TEARDOWN(group_name) \ 103 extern void group_##group_name##_teardown_wrapper_c(void); \ 104 void group_##group_name##_teardown_wrapper_c() 106 #define TEST_C(group_name, test_name) \ 107 extern void test_##group_name##_##test_name##_wrapper_c(void);\ 108 void test_##group_name##_##test_name##_wrapper_c() 113 #define TEST_GROUP_C_WRAPPER(group_name) \ 114 extern "C" void group_##group_name##_setup_wrapper_c(void); \ 115 extern "C" void group_##group_name##_teardown_wrapper_c(void); \ 116 TEST_GROUP(group_name) 118 #define TEST_GROUP_C_SETUP_WRAPPER(group_name) \ 120 group_##group_name##_setup_wrapper_c(); \ 123 #define TEST_GROUP_C_TEARDOWN_WRAPPER(group_name) \ 125 group_##group_name##_teardown_wrapper_c(); \ 128 #define TEST_C_WRAPPER(group_name, test_name) \ 129 extern "C" void test_##group_name##_##test_name##_wrapper_c(); \ 130 TEST(group_name, test_name) { \ 131 test_##group_name##_##test_name##_wrapper_c(); \ 141 extern void CHECK_EQUAL_C_BOOL_LOCATION(
int expected,
int actual,
142 const char* fileName,
int lineNumber);
143 extern void CHECK_EQUAL_C_INT_LOCATION(
int expected,
int actual,
144 const char* fileName,
int lineNumber);
145 extern void CHECK_EQUAL_C_UINT_LOCATION(
unsigned int expected,
unsigned int actual,
146 const char* fileName,
int lineNumber);
147 extern void CHECK_EQUAL_C_LONG_LOCATION(
long expected,
long actual,
148 const char* fileName,
int lineNumber);
149 extern void CHECK_EQUAL_C_ULONG_LOCATION(
unsigned long expected,
unsigned long actual,
150 const char* fileName,
int lineNumber);
151 extern void CHECK_EQUAL_C_LONGLONG_LOCATION(cpputest_longlong expected, cpputest_longlong actual,
152 const char* fileName,
int lineNumber);
153 extern void CHECK_EQUAL_C_ULONGLONG_LOCATION(cpputest_ulonglong expected, cpputest_ulonglong actual,
154 const char* fileName,
int lineNumber);
155 extern void CHECK_EQUAL_C_REAL_LOCATION(
double expected,
double actual,
156 double threshold,
const char* fileName,
int lineNumber);
157 extern void CHECK_EQUAL_C_CHAR_LOCATION(
char expected,
char actual,
158 const char* fileName,
int lineNumber);
159 extern void CHECK_EQUAL_C_UBYTE_LOCATION(
unsigned char expected,
unsigned char actual,
160 const char* fileName,
int lineNumber);
161 extern void CHECK_EQUAL_C_SBYTE_LOCATION(
signed char expected,
signed char actual,
162 const char* fileName,
int lineNumber);
163 extern void CHECK_EQUAL_C_STRING_LOCATION(
const char* expected,
164 const char* actual,
const char* fileName,
int lineNumber);
165 extern void CHECK_EQUAL_C_POINTER_LOCATION(
const void* expected,
166 const void* actual,
const char* fileName,
int lineNumber);
167 extern void CHECK_EQUAL_C_BITS_LOCATION(
unsigned int expected,
unsigned int actual,
168 unsigned int mask,
size_t size,
const char* fileName,
int lineNumber);
169 extern void FAIL_TEXT_C_LOCATION(
const char* text,
const char* fileName,
171 extern void FAIL_C_LOCATION(
const char* fileName,
int lineNumber);
172 extern void CHECK_C_LOCATION(
int condition,
const char* conditionString,
173 const char* fileName,
int lineNumber);
175 extern void* cpputest_malloc(
size_t size);
176 extern void* cpputest_calloc(
size_t num,
size_t size);
177 extern void* cpputest_realloc(
void* ptr,
size_t size);
178 extern void cpputest_free(
void* buffer);
180 extern void* cpputest_malloc_location(
size_t size,
const char* file,
int line);
181 extern void* cpputest_calloc_location(
size_t num,
size_t size,
182 const char* file,
int line);
183 extern void* cpputest_realloc_location(
void* memory,
size_t size,
184 const char* file,
int line);
185 extern void cpputest_free_location(
void* buffer,
const char* file,
int line);
187 void cpputest_malloc_set_out_of_memory(
void);
188 void cpputest_malloc_set_not_out_of_memory(
void);
189 void cpputest_malloc_set_out_of_memory_countdown(
int);
190 void cpputest_malloc_count_reset(
void);
191 int cpputest_malloc_get_count(
void);
204 #if defined(__GNUC__) 205 # define PUNUSED(x) PUNUSED_ ##x __attribute__((unused)) 207 # define PUNUSED(x) x