00001
00002
00003
00004 #ifndef DEV_W3_ORG__2001_BLINDFOLD_SRC_UNITTEST_H
00005 #define DEV_W3_ORG__2001_BLINDFOLD_SRC_UNITTEST_H
00006 #include "config.h"
00007
00008
00046 class UnitTest {
00047
00048 public:
00049
00050
00051 UnitTest(const UnitTest& other);
00052 const UnitTest& operator=(const UnitTest& other);
00053 bool operator==(const UnitTest& other) const;
00054 bool operator<(const UnitTest& other) const;
00055 size_t hash() const;
00056 friend std::ostream& operator<<(std::ostream& s, const UnitTest& me);
00057 std::ostream& print_to(std::ostream& stream) const;
00058 virtual ~UnitTest();
00059
00060
00061
00062 typedef bool (function)(std::ostream&);
00063
00064 UnitTest(function, char *file, int num, char *other_name);
00065
00066 static UnitTest* first_instance;
00067
00073 static void run_tests(std::ostream&, char *keyword);
00074
00075 void print_name(std::ostream& out);
00076
00077 private:
00078
00079 UnitTest* next_instance;
00080 function *function_pointer;
00081 char *file;
00082 int num;
00083 char *other_name;
00084 char *name;
00085 };
00086
00087
00088 #define UNIT_TEST(number, comment) \
00089 static UnitTest::function test##number; \
00090 static UnitTest holder_for_test##number(test##number, __FILE__, number, comment); \
00091 static bool test##number(std::ostream& out)
00092
00093 #define UNIT_TEST_FILE(comment) \
00094 \
00095 \
00096 static UnitTest::function test; \
00097 static UnitTest holder_for_test(test, __FILE__, 1, comment);
00098
00099 STANDARD_EXTERNAL(UnitTest)
00100
00101 #endif