Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __TF_TEST_H__
00031 #define __TF_TEST_H__
00032
00033 #include <time.h>
00034
00035 class TF_Test
00036 {
00037 typedef void MainFunc();
00038 const char *descr, *idstr;
00039 MainFunc *main;
00040 TF_Test *next;
00041 static TF_Test *first, *last;
00042 static int fails, runs;
00043 static time_t start_time;
00044
00045 static void alarm_handler(int sig);
00046
00047 public:
00048 TF_Test(const char *_descr, const char *_idstr, MainFunc *_main);
00049 static int run_all(const char * const *prefixes = NULL);
00050 static void start(const char *file, int line, const char *condstr);
00051 static void check(bool cond);
00052 static inline bool start_check(const char *file, int line,
00053 const char *condstr, bool cond)
00054 { start(file, line, condstr); check(cond); return cond; }
00055 static bool start_check_eq(const char *file, int line,
00056 const char *a, const char *b);
00057 static bool start_check_eq(const char *file, int line, int a, int b);
00058 };
00059
00060
00061
00062 #define TFPASS(cond) \
00063 TF_Test::start_check(__FILE__, __LINE__, #cond, (cond))
00064 #define TFPASSEQ(a, b) \
00065 TF_Test::start_check_eq(__FILE__, __LINE__, (a), (b))
00066
00067 #define TFFAIL(cond) \
00068 TF_Test::start_check(__FILE__, __LINE__, "NOT(" #cond ")", !(cond))
00069
00070 #define TFTEST_MAIN3(descr, ff, ll) \
00071 static void _tftest_main_##ll(); \
00072 static TF_Test _tftest_##ll(descr, ff, _tftest_main_##ll); \
00073 static void _tftest_main_##ll()
00074 #define TFTEST_MAIN2(descr, ff, ll) TFTEST_MAIN3(descr, ff, ll)
00075 #define TFTEST_MAIN(descr) TFTEST_MAIN2(descr, __FILE__, __COUNTER__)
00076
00077 #endif