Open Source Tomb Raider Engine
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

greatest.h 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /*
  2. * Copyright (c) 2011 Scott Vokes <vokes.s@gmail.com>
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef GREATEST_H
  17. #define GREATEST_H
  18. #ifdef __cplusplus
  19. #define __STDC_VERSION__ 19901L
  20. extern "C"
  21. {
  22. #endif
  23. #define GREATEST_VERSION_MAJOR 0
  24. #define GREATEST_VERSION_MINOR 9
  25. #define GREATEST_VERSION_PATCH 3
  26. /* A unit testing system for C, contained in 1 file.
  27. * It doesn't use dynamic allocation or depend on anything
  28. * beyond ANSI C89. */
  29. /*********************************************************************
  30. * Minimal test runner template
  31. *********************************************************************/
  32. #if 0
  33. #include "greatest.h"
  34. TEST foo_should_foo() {
  35. PASS();
  36. }
  37. static void setup_cb(void *data) {
  38. printf("setup callback for each test case\n");
  39. }
  40. static void teardown_cb(void *data) {
  41. printf("teardown callback for each test case\n");
  42. }
  43. SUITE(suite) {
  44. /* Optional setup/teardown callbacks which will be run before/after
  45. * every test case in the suite.
  46. * Cleared when the suite finishes. */
  47. SET_SETUP(setup_cb, voidp_to_callback_data);
  48. SET_TEARDOWN(teardown_cb, voidp_to_callback_data);
  49. RUN_TEST(foo_should_foo);
  50. }
  51. /* Add all the definitions that need to be in the test runner's main file. */
  52. GREATEST_MAIN_DEFS();
  53. int main(int argc, char **argv) {
  54. GREATEST_MAIN_BEGIN(); /* command-line arguments, initialization. */
  55. RUN_SUITE(suite);
  56. GREATEST_MAIN_END(); /* display results */
  57. }
  58. #endif
  59. /*********************************************************************/
  60. #include <stdlib.h>
  61. #include <stdio.h>
  62. #include <string.h>
  63. #include <time.h>
  64. /***********
  65. * Options *
  66. ***********/
  67. /* Default column width for non-verbose output. */
  68. #ifndef GREATEST_DEFAULT_WIDTH
  69. #define GREATEST_DEFAULT_WIDTH 72
  70. #endif
  71. /* FILE *, for test logging. */
  72. #ifndef GREATEST_STDOUT
  73. #define GREATEST_STDOUT stdout
  74. #endif
  75. /* Remove GREATEST_ prefix from most commonly used symbols? */
  76. #ifndef GREATEST_USE_ABBREVS
  77. #define GREATEST_USE_ABBREVS 1
  78. #endif
  79. /*********
  80. * Types *
  81. *********/
  82. /* Info for the current running suite. */
  83. typedef struct greatest_suite_info {
  84. unsigned int tests_run;
  85. unsigned int passed;
  86. unsigned int failed;
  87. unsigned int skipped;
  88. /* timers, pre/post running suite and individual tests */
  89. clock_t pre_suite;
  90. clock_t post_suite;
  91. clock_t pre_test;
  92. clock_t post_test;
  93. } greatest_suite_info;
  94. /* Type for a suite function. */
  95. typedef void (greatest_suite_cb)(void);
  96. /* Types for setup/teardown callbacks. If non-NULL, these will be run
  97. * and passed the pointer to their additional data. */
  98. typedef void (greatest_setup_cb)(void *udata);
  99. typedef void (greatest_teardown_cb)(void *udata);
  100. typedef enum {
  101. GREATEST_FLAG_VERBOSE = 0x01,
  102. GREATEST_FLAG_FIRST_FAIL = 0x02,
  103. GREATEST_FLAG_LIST_ONLY = 0x04
  104. } GREATEST_FLAG;
  105. typedef struct greatest_run_info {
  106. unsigned int flags;
  107. unsigned int tests_run; /* total test count */
  108. /* Overall pass/fail/skip counts. */
  109. unsigned int passed;
  110. unsigned int failed;
  111. unsigned int skipped;
  112. /* currently running test suite */
  113. greatest_suite_info suite;
  114. /* info to print about the most recent failure */
  115. const char *fail_file;
  116. unsigned int fail_line;
  117. const char *msg;
  118. /* current setup/teardown hooks and userdata */
  119. greatest_setup_cb *setup;
  120. void *setup_udata;
  121. greatest_teardown_cb *teardown;
  122. void *teardown_udata;
  123. /* formatting info for ".....s...F"-style output */
  124. unsigned int col;
  125. unsigned int width;
  126. /* only run a specific suite or test */
  127. char *suite_filter;
  128. char *test_filter;
  129. /* overall timers */
  130. clock_t begin;
  131. clock_t end;
  132. } greatest_run_info;
  133. /* Global var for the current testing context.
  134. * Initialized by GREATEST_MAIN_DEFS(). */
  135. extern greatest_run_info greatest_info;
  136. /**********************
  137. * Exported functions *
  138. **********************/
  139. void greatest_do_pass(const char *name);
  140. void greatest_do_fail(const char *name);
  141. void greatest_do_skip(const char *name);
  142. int greatest_pre_test(const char *name);
  143. void greatest_post_test(const char *name, int res);
  144. void greatest_usage(const char *name);
  145. void GREATEST_SET_SETUP_CB(greatest_setup_cb *cb, void *udata);
  146. void GREATEST_SET_TEARDOWN_CB(greatest_teardown_cb *cb, void *udata);
  147. /**********
  148. * Macros *
  149. **********/
  150. /* Define a suite. */
  151. #define GREATEST_SUITE(NAME) void NAME(void)
  152. /* Start defining a test function.
  153. * The arguments are not included, to allow parametric testing. */
  154. #define GREATEST_TEST static int
  155. /* Run a suite. */
  156. #define GREATEST_RUN_SUITE(S_NAME) greatest_run_suite(S_NAME, #S_NAME)
  157. /* Run a test in the current suite. */
  158. #define GREATEST_RUN_TEST(TEST) \
  159. do { \
  160. if (greatest_pre_test(#TEST) == 1) { \
  161. int res = TEST(); \
  162. greatest_post_test(#TEST, res); \
  163. } else if (GREATEST_LIST_ONLY()) { \
  164. fprintf(GREATEST_STDOUT, " %s\n", #TEST); \
  165. } \
  166. } while (0)
  167. /* Run a test in the current suite with one void* argument,
  168. * which can be a pointer to a struct with multiple arguments. */
  169. #define GREATEST_RUN_TEST1(TEST, ENV) \
  170. do { \
  171. if (greatest_pre_test(#TEST) == 1) { \
  172. int res = TEST(ENV); \
  173. greatest_post_test(#TEST, res); \
  174. } else if (GREATEST_LIST_ONLY()) { \
  175. fprintf(GREATEST_STDOUT, " %s\n", #TEST); \
  176. } \
  177. } while (0)
  178. /* If __VA_ARGS__ (C99) is supported, allow parametric testing
  179. * without needing to manually manage the argument struct. */
  180. #if __STDC_VERSION__ >= 19901L
  181. #define GREATEST_RUN_TESTp(TEST, ...) \
  182. do { \
  183. if (greatest_pre_test(#TEST) == 1) { \
  184. int res = TEST(__VA_ARGS__); \
  185. greatest_post_test(#TEST, res); \
  186. } else if (GREATEST_LIST_ONLY()) { \
  187. fprintf(GREATEST_STDOUT, " %s\n", #TEST); \
  188. } \
  189. } while (0)
  190. #endif
  191. /* Check if the test runner is in verbose mode. */
  192. #define GREATEST_IS_VERBOSE() (greatest_info.flags & GREATEST_FLAG_VERBOSE)
  193. #define GREATEST_LIST_ONLY() (greatest_info.flags & GREATEST_FLAG_LIST_ONLY)
  194. #define GREATEST_FIRST_FAIL() (greatest_info.flags & GREATEST_FLAG_FIRST_FAIL)
  195. #define GREATEST_FAILURE_ABORT() (greatest_info.suite.failed > 0 && GREATEST_FIRST_FAIL())
  196. /* Message-less forms. */
  197. #define GREATEST_PASS() GREATEST_PASSm(NULL)
  198. #define GREATEST_FAIL() GREATEST_FAILm(NULL)
  199. #define GREATEST_SKIP() GREATEST_SKIPm(NULL)
  200. #define GREATEST_ASSERT(COND) GREATEST_ASSERTm(#COND, COND)
  201. #define GREATEST_ASSERT_FALSE(COND) GREATEST_ASSERT_FALSEm(#COND, COND)
  202. #define GREATEST_ASSERT_EQ(EXP, GOT) GREATEST_ASSERT_EQm(#EXP " != " #GOT, EXP, GOT)
  203. #define GREATEST_ASSERT_STR_EQ(EXP, GOT) GREATEST_ASSERT_STR_EQm(#EXP " != " #GOT, EXP, GOT)
  204. /* The following forms take an additional message argument first,
  205. * to be displayed by the test runner. */
  206. /* Fail if a condition is not true, with message. */
  207. #define GREATEST_ASSERTm(MSG, COND) \
  208. do { \
  209. greatest_info.msg = MSG; \
  210. greatest_info.fail_file = __FILE__; \
  211. greatest_info.fail_line = __LINE__; \
  212. if (!(COND)) return -1; \
  213. greatest_info.msg = NULL; \
  214. } while (0)
  215. #define GREATEST_ASSERT_FALSEm(MSG, COND) \
  216. do { \
  217. greatest_info.msg = MSG; \
  218. greatest_info.fail_file = __FILE__; \
  219. greatest_info.fail_line = __LINE__; \
  220. if ((COND)) return -1; \
  221. greatest_info.msg = NULL; \
  222. } while (0)
  223. #define GREATEST_ASSERT_EQm(MSG, EXP, GOT) \
  224. do { \
  225. greatest_info.msg = MSG; \
  226. greatest_info.fail_file = __FILE__; \
  227. greatest_info.fail_line = __LINE__; \
  228. if ((EXP) != (GOT)) return -1; \
  229. greatest_info.msg = NULL; \
  230. } while (0)
  231. #define GREATEST_ASSERT_STR_EQm(MSG, EXP, GOT) \
  232. do { \
  233. const char *exp_s = (EXP); \
  234. const char *got_s = (GOT); \
  235. greatest_info.msg = MSG; \
  236. greatest_info.fail_file = __FILE__; \
  237. greatest_info.fail_line = __LINE__; \
  238. if (0 != strcmp(exp_s, got_s)) { \
  239. fprintf(GREATEST_STDOUT, \
  240. "Expected:\n####\n%s\n####\n", exp_s); \
  241. fprintf(GREATEST_STDOUT, \
  242. "Got:\n####\n%s\n####\n", got_s); \
  243. return -1; \
  244. } \
  245. greatest_info.msg = NULL; \
  246. } while (0)
  247. #define GREATEST_PASSm(MSG) \
  248. do { \
  249. greatest_info.msg = MSG; \
  250. return 0; \
  251. } while (0)
  252. #define GREATEST_FAILm(MSG) \
  253. do { \
  254. greatest_info.fail_file = __FILE__; \
  255. greatest_info.fail_line = __LINE__; \
  256. greatest_info.msg = MSG; \
  257. return -1; \
  258. } while (0)
  259. #define GREATEST_SKIPm(MSG) \
  260. do { \
  261. greatest_info.msg = MSG; \
  262. return 1; \
  263. } while (0)
  264. #define GREATEST_SET_TIME(NAME) \
  265. NAME = clock(); \
  266. if (NAME == (clock_t) -1) { \
  267. fprintf(GREATEST_STDOUT, \
  268. "clock error: %s\n", #NAME); \
  269. exit(EXIT_FAILURE); \
  270. }
  271. #define GREATEST_CLOCK_DIFF(C1, C2) \
  272. fprintf(GREATEST_STDOUT, " (%lu ticks, %.3f sec)", \
  273. (long unsigned int) (C2) - (C1), \
  274. (double)((C2) - (C1)) / (1.0 * (double)CLOCKS_PER_SEC)) \
  275. /* Include several function definitions in the main test file. */
  276. #define GREATEST_MAIN_DEFS() \
  277. \
  278. /* Is FILTER a subset of NAME? */ \
  279. static int greatest_name_match(const char *name, \
  280. const char *filter) { \
  281. size_t offset = 0; \
  282. size_t filter_len = strlen(filter); \
  283. while (name[offset] != '\0') { \
  284. if (name[offset] == filter[0]) { \
  285. if (0 == strncmp(&name[offset], filter, filter_len)) { \
  286. return 1; \
  287. } \
  288. } \
  289. offset++; \
  290. } \
  291. \
  292. return 0; \
  293. } \
  294. \
  295. int greatest_pre_test(const char *name) { \
  296. if (!GREATEST_LIST_ONLY() \
  297. && (!GREATEST_FIRST_FAIL() || greatest_info.suite.failed == 0) \
  298. && (greatest_info.test_filter == NULL || \
  299. greatest_name_match(name, greatest_info.test_filter))) { \
  300. GREATEST_SET_TIME(greatest_info.suite.pre_test); \
  301. if (greatest_info.setup) { \
  302. greatest_info.setup(greatest_info.setup_udata); \
  303. } \
  304. return 1; /* test should be run */ \
  305. } else { \
  306. return 0; /* skipped */ \
  307. } \
  308. } \
  309. \
  310. void greatest_post_test(const char *name, int res) { \
  311. GREATEST_SET_TIME(greatest_info.suite.post_test); \
  312. if (greatest_info.teardown) { \
  313. void *udata = greatest_info.teardown_udata; \
  314. greatest_info.teardown(udata); \
  315. } \
  316. \
  317. if (res < 0) { \
  318. greatest_do_fail(name); \
  319. } else if (res > 0) { \
  320. greatest_do_skip(name); \
  321. } else if (res == 0) { \
  322. greatest_do_pass(name); \
  323. } \
  324. greatest_info.suite.tests_run++; \
  325. greatest_info.col++; \
  326. if (GREATEST_IS_VERBOSE()) { \
  327. GREATEST_CLOCK_DIFF(greatest_info.suite.pre_test, \
  328. greatest_info.suite.post_test); \
  329. fprintf(GREATEST_STDOUT, "\n"); \
  330. } else if (greatest_info.col % greatest_info.width == 0) { \
  331. fprintf(GREATEST_STDOUT, "\n"); \
  332. greatest_info.col = 0; \
  333. } \
  334. if (GREATEST_STDOUT == stdout) fflush(stdout); \
  335. } \
  336. \
  337. static void greatest_run_suite(greatest_suite_cb *suite_cb, \
  338. const char *suite_name) { \
  339. if (greatest_info.suite_filter && \
  340. !greatest_name_match(suite_name, greatest_info.suite_filter)) \
  341. return; \
  342. if (GREATEST_FIRST_FAIL() && greatest_info.failed > 0) return; \
  343. greatest_info.suite.tests_run = 0; \
  344. greatest_info.suite.failed = 0; \
  345. greatest_info.suite.passed = 0; \
  346. greatest_info.suite.skipped = 0; \
  347. greatest_info.suite.pre_suite = 0; \
  348. greatest_info.suite.post_suite = 0; \
  349. greatest_info.suite.pre_test = 0; \
  350. greatest_info.suite.post_test = 0; \
  351. greatest_info.col = 0; \
  352. fprintf(GREATEST_STDOUT, "\n* Suite %s:\n", suite_name); \
  353. GREATEST_SET_TIME(greatest_info.suite.pre_suite); \
  354. suite_cb(); \
  355. GREATEST_SET_TIME(greatest_info.suite.post_suite); \
  356. if (greatest_info.suite.tests_run > 0) { \
  357. fprintf(GREATEST_STDOUT, \
  358. "\n%u tests - %u pass, %u fail, %u skipped", \
  359. greatest_info.suite.tests_run, \
  360. greatest_info.suite.passed, \
  361. greatest_info.suite.failed, \
  362. greatest_info.suite.skipped); \
  363. GREATEST_CLOCK_DIFF(greatest_info.suite.pre_suite, \
  364. greatest_info.suite.post_suite); \
  365. fprintf(GREATEST_STDOUT, "\n"); \
  366. } \
  367. greatest_info.setup = NULL; \
  368. greatest_info.setup_udata = NULL; \
  369. greatest_info.teardown = NULL; \
  370. greatest_info.teardown_udata = NULL; \
  371. greatest_info.passed += greatest_info.suite.passed; \
  372. greatest_info.failed += greatest_info.suite.failed; \
  373. greatest_info.skipped += greatest_info.suite.skipped; \
  374. greatest_info.tests_run += greatest_info.suite.tests_run; \
  375. } \
  376. \
  377. void greatest_do_pass(const char *name) { \
  378. if (GREATEST_IS_VERBOSE()) { \
  379. fprintf(GREATEST_STDOUT, "PASS %s: %s", \
  380. name, greatest_info.msg ? greatest_info.msg : ""); \
  381. } else { \
  382. fprintf(GREATEST_STDOUT, "."); \
  383. } \
  384. greatest_info.suite.passed++; \
  385. } \
  386. \
  387. void greatest_do_fail(const char *name) { \
  388. if (GREATEST_IS_VERBOSE()) { \
  389. fprintf(GREATEST_STDOUT, \
  390. "FAIL %s: %s (%s:%u)", \
  391. name, greatest_info.msg ? greatest_info.msg : "", \
  392. greatest_info.fail_file, greatest_info.fail_line); \
  393. } else { \
  394. fprintf(GREATEST_STDOUT, "F"); \
  395. /* add linebreak if in line of '.'s */ \
  396. if (greatest_info.col % greatest_info.width != 0) \
  397. fprintf(GREATEST_STDOUT, "\n"); \
  398. greatest_info.col = 0; \
  399. fprintf(GREATEST_STDOUT, "FAIL %s: %s (%s:%u)\n", \
  400. name, \
  401. greatest_info.msg ? greatest_info.msg : "", \
  402. greatest_info.fail_file, greatest_info.fail_line); \
  403. } \
  404. greatest_info.suite.failed++; \
  405. } \
  406. \
  407. void greatest_do_skip(const char *name) { \
  408. if (GREATEST_IS_VERBOSE()) { \
  409. fprintf(GREATEST_STDOUT, "SKIP %s: %s", \
  410. name, \
  411. greatest_info.msg ? \
  412. greatest_info.msg : "" ); \
  413. } else { \
  414. fprintf(GREATEST_STDOUT, "s"); \
  415. } \
  416. greatest_info.suite.skipped++; \
  417. } \
  418. \
  419. void greatest_usage(const char *name) { \
  420. fprintf(GREATEST_STDOUT, \
  421. "Usage: %s [-hlfv] [-s SUITE] [-t TEST]\n" \
  422. " -h print this Help\n" \
  423. " -l List suites and their tests, then exit\n" \
  424. " -f Stop runner after first failure\n" \
  425. " -v Verbose output\n" \
  426. " -s SUITE only run suite named SUITE\n" \
  427. " -t TEST only run test named TEST\n", \
  428. name); \
  429. } \
  430. \
  431. void GREATEST_SET_SETUP_CB(greatest_setup_cb *cb, void *udata) { \
  432. greatest_info.setup = cb; \
  433. greatest_info.setup_udata = udata; \
  434. } \
  435. \
  436. void GREATEST_SET_TEARDOWN_CB(greatest_teardown_cb *cb, \
  437. void *udata) { \
  438. greatest_info.teardown = cb; \
  439. greatest_info.teardown_udata = udata; \
  440. } \
  441. \
  442. greatest_run_info greatest_info
  443. /* Handle command-line arguments, etc. */
  444. #define GREATEST_MAIN_BEGIN() \
  445. do { \
  446. int i = 0; \
  447. memset(&greatest_info, 0, sizeof(greatest_info)); \
  448. if (greatest_info.width == 0) { \
  449. greatest_info.width = GREATEST_DEFAULT_WIDTH; \
  450. } \
  451. for (i = 1; i < argc; i++) { \
  452. if (0 == strcmp("-t", argv[i])) { \
  453. if (argc <= i + 1) { \
  454. greatest_usage(argv[0]); \
  455. exit(EXIT_FAILURE); \
  456. } \
  457. greatest_info.test_filter = argv[i+1]; \
  458. i++; \
  459. } else if (0 == strcmp("-s", argv[i])) { \
  460. if (argc <= i + 1) { \
  461. greatest_usage(argv[0]); \
  462. exit(EXIT_FAILURE); \
  463. } \
  464. greatest_info.suite_filter = argv[i+1]; \
  465. i++; \
  466. } else if (0 == strcmp("-f", argv[i])) { \
  467. greatest_info.flags |= GREATEST_FLAG_FIRST_FAIL; \
  468. } else if (0 == strcmp("-v", argv[i])) { \
  469. greatest_info.flags |= GREATEST_FLAG_VERBOSE; \
  470. } else if (0 == strcmp("-l", argv[i])) { \
  471. greatest_info.flags |= GREATEST_FLAG_LIST_ONLY; \
  472. } else if (0 == strcmp("-h", argv[i])) { \
  473. greatest_usage(argv[0]); \
  474. exit(EXIT_SUCCESS); \
  475. } else { \
  476. fprintf(GREATEST_STDOUT, \
  477. "Unknown argument '%s'\n", argv[i]); \
  478. greatest_usage(argv[0]); \
  479. exit(EXIT_FAILURE); \
  480. } \
  481. } \
  482. } while (0); \
  483. GREATEST_SET_TIME(greatest_info.begin)
  484. #define GREATEST_MAIN_END() \
  485. do { \
  486. if (!GREATEST_LIST_ONLY()) { \
  487. GREATEST_SET_TIME(greatest_info.end); \
  488. fprintf(GREATEST_STDOUT, \
  489. "\nTotal: %u tests", greatest_info.tests_run); \
  490. GREATEST_CLOCK_DIFF(greatest_info.begin, \
  491. greatest_info.end); \
  492. fprintf(GREATEST_STDOUT, "\n"); \
  493. fprintf(GREATEST_STDOUT, \
  494. "Pass: %u, fail: %u, skip: %u.\n", \
  495. greatest_info.passed, \
  496. greatest_info.failed, greatest_info.skipped); \
  497. } \
  498. return (greatest_info.failed > 0 \
  499. ? EXIT_FAILURE : EXIT_SUCCESS); \
  500. } while (0)
  501. /* Make abbreviations without the GREATEST_ prefix for the
  502. * most commonly used symbols. */
  503. #if GREATEST_USE_ABBREVS
  504. #define TEST GREATEST_TEST
  505. #define SUITE GREATEST_SUITE
  506. #define RUN_TEST GREATEST_RUN_TEST
  507. #define RUN_TEST1 GREATEST_RUN_TEST1
  508. #define RUN_SUITE GREATEST_RUN_SUITE
  509. #define ASSERT GREATEST_ASSERT
  510. #define ASSERTm GREATEST_ASSERTm
  511. #define ASSERT_FALSE GREATEST_ASSERT_FALSE
  512. #define ASSERT_EQ GREATEST_ASSERT_EQ
  513. #define ASSERT_STR_EQ GREATEST_ASSERT_STR_EQ
  514. #define ASSERT_FALSEm GREATEST_ASSERT_FALSEm
  515. #define ASSERT_EQm GREATEST_ASSERT_EQm
  516. #define ASSERT_STR_EQm GREATEST_ASSERT_STR_EQm
  517. #define PASS GREATEST_PASS
  518. #define FAIL GREATEST_FAIL
  519. #define SKIP GREATEST_SKIP
  520. #define PASSm GREATEST_PASSm
  521. #define FAILm GREATEST_FAILm
  522. #define SKIPm GREATEST_SKIPm
  523. #define SET_SETUP GREATEST_SET_SETUP_CB
  524. #define SET_TEARDOWN GREATEST_SET_TEARDOWN_CB
  525. #if __STDC_VERSION__ >= 19901L
  526. #endif /* C99 */
  527. #define RUN_TESTp GREATEST_RUN_TESTp
  528. #endif /* USE_ABBREVS */
  529. #ifdef __cplusplus
  530. }
  531. #endif
  532. #endif