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

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