00001 #ifndef INCLUDED_T_MAIN_HH
00002 #define INCLUDED_T_MAIN_HH
00003
00004 #ifndef TYPES_ARG_TRAITS_HH
00005 #include "Types/arg_traits.hh"
00006 #endif
00007
00008 #include "SkippedException.hh"
00009
00010 extern int fatalmind_trace_malloc;
00011 void dumpLeakedMemory();
00012
00013 #include <string>
00014
00015 #define assertTrue(x) _assertTrue(x, "assertTrue", __FILE__, __LINE__);
00016 #define assertFalse(x) _assertTrue(!(x), "assertFalse", __FILE__, __LINE__);
00017
00018 #define assertNotPass() _assertNotPass(__FILE__, __LINE__)
00019 #define assertNotReach() _assertNotPass(__FILE__, __LINE__)
00020
00021 #define assertEqual(i, e) _assertEqual((i), (e), __FILE__, __LINE__)
00022 #define assertEqualT(t, i, e) _assertEqual<t>((i), (e), __FILE__, __LINE__)
00023 #define assertNotEqual(i, e) _assertNotEqual<>((i), (e), __FILE__, __LINE__)
00024 #define assertNotEqualT(t, i, e) _assertNotEqual<t>((i), (e), __FILE__, __LINE__)
00025 #define assertLess(i, e) _assertLess<>((i), (e), __FILE__, __LINE__)
00026 #define assertLessT(t, i, e) _assertLess<t>((i), (e), __FILE__, __LINE__)
00027 #define assertNotLess(i, e) _assertNotLess<>((i), (e), __FILE__, __LINE__)
00028 #define assertNotLessT(t, i, e) _assertNotLess<t>((i), (e), __FILE__, __LINE__)
00029 #define assertMore(i, e) _assertMore<>((i), (e), __FILE__, __LINE__)
00030 #define assertMoreT(t, i, e) _assertMore<t>((i), (e), __FILE__, __LINE__)
00031 #define assertNotMore(i, e) _assertNotMore<>((i), (e), __FILE__, __LINE__)
00032 #define assertNotMoreT(t, i, e) _assertNotMore<t>((i), (e), __FILE__, __LINE__)
00033
00034 #define assertNotGrowing(skipi) {static struct fatalmind_test_size sz; _assertNotGrown(sz, (skipi), __FILE__, __LINE__); }
00035
00036
00037
00038 template <typename T>
00039 void _assertEqual(
00040 typename fatalmind::arg_traits<T>::const_param is
00041 , typename fatalmind::arg_traits<T>::const_param expect
00042 , const char* file
00043 , int line
00044 );
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 template<>
00057 void _assertEqual<std::string>(
00058 fatalmind::arg_traits<std::string>::const_param is
00059 , fatalmind::arg_traits<std::string>::const_param expect
00060 , const char* file
00061 , int line
00062 );
00063
00064 void _assertEqual(
00065 const int is
00066 , const int expect
00067 , const char* file
00068 , int line
00069 );
00070
00071 void _assertEqual(
00072 const std::string& is
00073 , const std::string expect
00074 , const char* file
00075 , int line
00076 );
00077
00078
00079
00080 template <class T>
00081 void _assertLess(T actual, T limit, const char* file, int line);
00082
00083 template <class T>
00084 void _assertNotLess(T actual, T limit, const char* file, int line);
00085
00086 template <class T>
00087 void _assertMore(T actual, T limit, const char* file, int line);
00088
00089 template <class T>
00090 void _assertNotMore(T actual, T limit, const char* file, int line);
00091
00092 template <class T>
00093 void _assertNotEqual(T is, T expect, const char* file, int line);
00094
00095 void _assertNotPass(const char* file, int line);
00096 void _assertTrue(bool b, const char* s, const char* file, int line);
00097
00098 struct fatalmind_test_size {
00099 long ru_idrss;
00100 int icount;
00101 };
00102
00103 void _assertNotGrown(fatalmind_test_size& sz, int skipiter, const char* file, int line);
00104
00105
00106 class tester {
00107 public:
00108 tester(int, int);
00109 virtual ~tester() {
00110 }
00111
00112 int run_tests();
00113 int run_allperf();
00114 virtual void init() = 0;
00115 virtual void cleanup() = 0;
00116 virtual void normal_test() = 0;
00117 virtual void run_perf() = 0;
00118 virtual void run_single_perf(int i) = 0;
00119 virtual const char* get_single_perf_name(int i) = 0;
00120 virtual int getSinglePerfTests() = 0;
00121 void test_it(void func(), const char *name);
00122 void printSummary();
00123 int getFAIL() {
00124 return FAIL;
00125 }
00126 int getSKIPPED() {
00127 return SKIPPED;
00128 }
00129 int getOK() {
00130 return OK;
00131 }
00132 private:
00133 int FAIL, num, OK, SKIPPED;
00134 int silent, loop;
00135 };
00136
00137 #include "assert.cc"
00138
00139 #endif