1 /* Miniature re-implementation of the "check" library.
3 This is intended to support just enough of check to run the Expat
4 tests. This interface is based entirely on the portion of the
5 check library being used.
7 This is *source* compatible, but not necessary *link* compatible.
10 / _ \\ /| '_ \ / _` | __|
11 | __// \| |_) | (_| | |_
12 \___/_/\_\ .__/ \__,_|\__|
15 Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
16 Copyright (c) 2000-2017 Expat development team
17 Licensed under the MIT license:
19 Permission is hereby granted, free of charge, to any person obtaining
20 a copy of this software and associated documentation files (the
21 "Software"), to deal in the Software without restriction, including
22 without limitation the rights to use, copy, modify, merge, publish,
23 distribute, sublicense, and/or sell copies of the Software, and to permit
24 persons to whom the Software is furnished to do so, subject to the
27 The above copyright notice and this permission notice shall be included
28 in all copies or substantial portions of the Software.
30 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
33 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
35 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
36 USE OR OTHER DEALINGS IN THE SOFTWARE.
50 /* Workaround for Microsoft's compiler and Tru64 Unix systems where the
51 C compiler has a working __func__, but the C++ compiler only has a
52 working __FUNCTION__. This could be fixed in configure.in, but it's
53 not worth it right now. */
54 #if defined (_MSC_VER) || (defined(__osf__) && defined(__cplusplus))
55 #define __func__ __FUNCTION__
58 #define START_TEST(testname) static void testname(void) { \
59 _check_set_test_info(__func__, __FILE__, __LINE__); \
63 #define fail(msg) _fail_unless(0, __FILE__, __LINE__, msg)
65 typedef void (*tcase_setup_function)(void);
66 typedef void (*tcase_teardown_function)(void);
67 typedef void (*tcase_test_function)(void);
69 typedef struct SRunner SRunner;
70 typedef struct Suite Suite;
71 typedef struct TCase TCase;
86 tcase_setup_function setup;
87 tcase_teardown_function teardown;
88 tcase_test_function *tests;
95 /* Internal helper. */
96 void _check_set_test_info(char const *function,
97 char const *filename, int lineno);
101 * Prototypes for the actual implementation.
104 void _fail_unless(int condition, const char *file, int line, const char *msg);
105 Suite *suite_create(const char *name);
106 TCase *tcase_create(const char *name);
107 void suite_add_tcase(Suite *suite, TCase *tc);
108 void tcase_add_checked_fixture(TCase *,
109 tcase_setup_function,
110 tcase_teardown_function);
111 void tcase_add_test(TCase *tc, tcase_test_function test);
112 SRunner *srunner_create(Suite *suite);
113 void srunner_run_all(SRunner *runner, int verbosity);
114 int srunner_ntests_failed(SRunner *runner);
115 void srunner_free(SRunner *runner);