[LWIP]
[reactos.git] / lib / drivers / lwip / test / unit / lwip_check.h
1 #ifndef __LWIP_CHECK_H__
2 #define __LWIP_CHECK_H__
3
4 /* Common header file for lwIP unit tests using the check framework */
5
6 #include <config.h>
7 #include <check.h>
8 #include <stdlib.h>
9
10 #define FAIL_RET() do { fail(); return; } while(0)
11 #define EXPECT(x) fail_unless(x)
12 #define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0)
13 #define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0)
14 #define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL)
15
16 /** typedef for a function returning a test suite */
17 typedef Suite* (suite_getter_fn)(void);
18
19 /** Create a test suite */
20 static Suite* create_suite(const char* name, TFun *tests, size_t num_tests, SFun setup, SFun teardown)
21 {
22 size_t i;
23 Suite *s = suite_create(name);
24
25 for(i = 0; i < num_tests; i++) {
26 // Core test case
27 TCase *tc_core = tcase_create("Core");
28 if ((setup != NULL) || (teardown != NULL)) {
29 tcase_add_checked_fixture(tc_core, setup, teardown);
30 }
31 tcase_add_test(tc_core, tests[i]);
32 suite_add_tcase(s, tc_core);
33 }
34 return s;
35 }
36
37 #endif /* __LWIP_CHECK_H__ */