24 #include "CUnit/CUnit.h" 25 #include "CUnit/Automated.h" 27 int focunit_main(
int argc,
char **argv,
char *test_name, CU_SuiteInfo *
suites);
43 #define FO_PASS(msg) CU_PASS(msg) 48 #define FO_ASSERT(value) CU_ASSERT(value) 53 #define FO_ASSERT_FATAL(value) CU_ASSERT_FATAL(value) 58 #define FO_TEST(value) CU_TEST(value) 63 #define FO_TEST_FATAL(value) CU_TEST_FATAL(value) 66 #define FO_FAIL(msg) CU_FAIL(msg) 69 #define FO_FAIL_FATAL(msg) CU_FAIL_FATAL(msg) 74 #define FO_ASSERT_TRUE(value) CU_ASSERT_TRUE(value) 79 #define FO_ASSERT_TRUE_FATAL(value) CU_ASSERT_TRUE_FATAL(value) 84 #define FO_ASSERT_FALSE(value) CU_ASSERT_FALSE(value) 89 #define FO_ASSERT_FALSE_FATAL(value) CU_ASSERT_FALSE_FATAL(value) 94 #define FO_ASSERT_EQUAL(actual, expected) \ 96 if (actual != expected) printf("%s(%d) Expected %d, got %d\n",\ 97 __FILE__,__LINE__, expected, actual);\ 98 CU_ASSERT_EQUAL(actual, expected)\ 104 #define FO_ASSERT_EQUAL_FATAL(actual, expected) \ 106 if (actual != expected) printf("FATAL: %s(%d) Expected %d, got %d\n",\ 107 __FILE__,__LINE__, expected, actual);\ 108 CU_ASSERT_EQUAL_FATAL(actual, expected)\ 114 #define FO_ASSERT_NOT_EQUAL(actual, expected) \ 116 if (actual == expected) printf("%s(%d) Expected != %d got %d\n",\ 117 __FILE__,__LINE__, expected, actual);\ 118 CU_ASSERT_NOT_EQUAL(actual, expected)\ 124 #define FO_ASSERT_NOT_EQUAL_FATAL(actual, expected) \ 126 if (actual == expected) printf("FATAL: %s(%d) Expected != %d, got %d\n",\ 127 __FILE__,__LINE__, expected, actual);\ 128 CU_ASSERT_NOT_EQUAL_FATAL(actual, expected)\ 134 #define FO_ASSERT_PTR_EQUAL(actual, expected) \ 136 if (actual != expected) printf("%s(%d) Expected %p, got %p\n",\ 137 __FILE__,__LINE__, expected, actual);\ 138 CU_ASSERT_PTR_EQUAL(actual, expected)\ 144 #define FO_ASSERT_PTR_EQUAL_FATAL(actual, expected) \ 146 if (actual != expected) printf("FATAL: %s(%d) Expected %p, got %p\n",\ 147 __FILE__,__LINE__, expected, actual);\ 148 CU_ASSERT_PTR_EQUAL_FATAL(actual, expected)\ 154 #define FO_ASSERT_PTR_NOT_EQUAL(actual, expected) \ 156 if (actual == expected) printf("%s(%d) Expected != %p got %p\n",\ 157 __FILE__,__LINE__, expected, actual);\ 158 CU_ASSERT_PTR_NOT_EQUAL(actual, expected)\ 164 #define FO_ASSERT_PTR_NOT_EQUAL_FATAL(actual, expected) \ 166 if (actual == expected) printf("FATAL: %s(%d) Expected != %p, got %p\n",\ 167 __FILE__,__LINE__, expected, actual);\ 168 CU_ASSERT_PTR_NOT_EQUAL_FATAL(actual, expected)\ 174 #define FO_ASSERT_PTR_NULL(value) CU_ASSERT_PTR_NULL(value) 179 #define FO_ASSERT_PTR_NULL_FATAL(value) CU_ASSERT_PTR_NULL_FATAL(value) 184 #define FO_ASSERT_PTR_NOT_NULL(value) CU_ASSERT_PTR_NOT_NULL(value) 189 #define FO_ASSERT_PTR_NOT_NULL_FATAL(value) CU_ASSERT_PTR_NOT_NULL_FATAL(value) 194 #define FO_ASSERT_STRING_EQUAL(actual, expected) \ 196 FO_ASSERT_PTR_NOT_NULL_FATAL(actual); \ 197 if (0 != (strcmp((const char*)(actual), (const char*)(expected)))) \ 198 printf("%s(%d) Expected (%s), got (%s)\n", __FILE__,__LINE__, expected, actual);\ 199 CU_ASSERT_STRING_EQUAL(actual, expected)\ 205 #define FO_ASSERT_STRING_EQUAL_FATAL(actual, expected) \ 207 if (0 != (strcmp((const char*)(actual), (const char*)(expected)))) \ 208 printf("FATAL: %s(%d) Expected (%s), got (%s)\n", __FILE__,__LINE__, expected, actual);\ 209 CU_ASSERT_STRING_EQUAL_FATAL(actual, expected)\ 215 #define FO_ASSERT_STRING_NOT_EQUAL(actual, expected) \ 217 if (0 == strcmp((const char*)(actual), (const char*)(expected))) \ 218 printf("%s(%d) Expected != (%s), got (%s)\n", __FILE__,__LINE__, expected, actual);\ 219 CU_ASSERT_STRING_NOT_EQUAL(actual, expected)\ 225 #define FO_ASSERT_STRING_NOT_EQUAL_FATAL(actual, expected) \ 227 if (0 == strcmp((const char*)(actual), (const char*)(expected))) \ 228 printf("FATAL: %s(%d) Expected != (%s), got (%s)\n", __FILE__,__LINE__, expected, actual);\ 229 CU_ASSERT_STRING_NOT_EQUAL_FATAL(actual, expected)\ 236 #define FO_ASSERT_NSTRING_EQUAL(actual, expected, count) \ 238 if (0 != strcmp((const char*)(actual), (const char*)(expected), (size_t)(count))) \ 239 printf("%s(%d) Expected (%s), got (%s)\n", __FILE__,__LINE__, expected, actual);\ 240 CU_ASSERT_NSTRING_EQUAL(actual, expected, count)\ 247 #define FO_ASSERT_NSTRING_EQUAL_FATAL(actual, expected, count) \ 249 if (0 != strcmp((const char*)(actual), (const char*)(expected), (size_t)(count))) \ 250 printf("FATAL: %s(%d) Expected (%s), got (%s)\n", __FILE__,__LINE__, expected, actual);\ 251 CU_ASSERT_NSTRING_EQUAL_FATAL(actual, expected, count)\ 258 #define FO_ASSERT_NSTRING_NOT_EQUAL(actual, expected, count) \ 260 if (0 == strcmp((const char*)(actual), (const char*)(expected), (size_t)(count))) \ 261 printf("%s(%d) Expected (%s), got (%s)\n", __FILE__,__LINE__, expected, actual);\ 262 CU_ASSERT_NSTRING_NOT_EQUAL(actual, expected, count)\ 269 #define FO_ASSERT_NSTRING_NOT_EQUAL_FATAL(actual, expected, count) \ 271 if (0 == strcmp((const char*)(actual), (const char*)(expected), (size_t)(count))) \ 272 printf("FATAL: %s(%d) Expected (%s), got (%s)\n", __FILE__,__LINE__, expected, actual);\ 273 CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(actual, expected, count)\ 280 #define FO_ASSERT_DOUBLE_EQUAL(actual, expected, granularity) \ 282 if (fabs((double)(actual) - (expected)) >= fabs((double)(granularity))) \ 283 printf("%s(%d) Expected %f, got %f\n", __FILE__,__LINE__, expected, actual);\ 284 CU_ASSERT_DOUBLE_EQUAL(actual, expected, granularity)\ 291 #define FO_ASSERT_DOUBLE_EQUAL_FATAL(actual, expected, granularity) \ 293 if (fabs((double)(actual) - (expected)) >= fabs((double)(granularity))) \ 294 printf("FATAL: %s(%d) Expected %f, got %f\n", __FILE__,__LINE__, expected, actual);\ 295 CU_ASSERT_DOUBLE_EQUAL_FATAL(actual, expected, granularity)\ 302 #define FO_ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity) \ 304 if (fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))\ 305 printf("%s(%d) Expected %f, got %f\n", __FILE__,__LINE__, expected, actual);\ 306 CU_ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity)\ 313 #define FO_ASSERT_DOUBLE_NOT_EQUAL_FATAL(actual, expected, granularity) \ 315 if (fabs((double)(actual) - (expected)) <= fabs((double)(granularity))) \ 316 printf("FATAL: %s(%d) Expected %f, got %f\n", __FILE__,__LINE__, expected, actual);\ 317 CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(actual, expected, granularity)\ CU_SuiteInfo suites[]
all test suites for delagent