00001 #ifndef __LWIP_CHECK_H__
00002 #define __LWIP_CHECK_H__
00003
00004
00005
00006 #include <config.h>
00007 #include <check.h>
00008 #include <stdlib.h>
00009
00010 #define FAIL_RET() do { fail(); return; } while(0)
00011 #define EXPECT(x) fail_unless(x)
00012 #define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0)
00013 #define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0)
00014 #define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL)
00015
00016
00017 typedef Suite* (suite_getter_fn)(void);
00018
00019
00020 static Suite* create_suite(const char* name, TFun *tests, size_t num_tests, SFun setup, SFun teardown)
00021 {
00022 size_t i;
00023 Suite *s = suite_create(name);
00024
00025 for(i = 0; i < num_tests; i++) {
00026
00027 TCase *tc_core = tcase_create("Core");
00028 if ((setup != NULL) || (teardown != NULL)) {
00029 tcase_add_checked_fixture(tc_core, setup, teardown);
00030 }
00031 tcase_add_test(tc_core, tests[i]);
00032 suite_add_tcase(s, tc_core);
00033 }
00034 return s;
00035 }
00036
00037 #endif