00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __WVTEST_H
00013 #define __WVTEST_H
00014
00015 class WvTest
00016 {
00017 typedef void MainFunc();
00018 const char *idstr;
00019 MainFunc *main;
00020 WvTest *next;
00021 static WvTest *first, *last;
00022 static int fails, runs;
00023
00024 public:
00025 WvTest(const char *_idstr, MainFunc *_main);
00026 static int run_all(const char *prefix = "");
00027 static void start(const char *file, int line, const char *condstr);
00028 static void check(bool cond);
00029 };
00030
00031
00032 #define WVPASS(cond) do { \
00033 WvTest::start(__FILE__, __LINE__, #cond); \
00034 WvTest::check((cond)); \
00035 } while (0)
00036
00037 #define WVFAIL(cond) do { \
00038 WvTest::start(__FILE__, __LINE__, "NOT(" #cond ")"); \
00039 WvTest::check(!(cond)); \
00040 } while (0)
00041
00042 #define WVTEST_MAIN3(ff, ll) \
00043 static void _wvtest_main_##ll(); \
00044 static WvTest _wvtest_##ll(ff, _wvtest_main_##ll); \
00045 static void _wvtest_main_##ll
00046 #define WVTEST_MAIN2(ff, ll) WVTEST_MAIN3(ff, ll)
00047 #define WVTEST_MAIN WVTEST_MAIN2(__FILE__, __LINE__)
00048
00049
00050 #endif // __WVTEST_H