Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

UnitTest.h

00001 // See the file LICENSE in the some directory as this file for legal
00002 // notices about this software.   
00003 // $Id: UnitTest_8h-source.html,v 1.11 2001/10/10 20:40:58 sandro Exp $
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     // STANDARD MEMBER FUNCTIONS
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     // CLASS-SPECIFIC PUBLIC INTERFACE
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;  // assumed to be static stored; never free this
00082     int num;
00083     char *other_name;   // assumed to be static stored; never free this
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 /* single comment */ \
00096 static UnitTest::function test; \
00097 static UnitTest holder_for_test(test, __FILE__, 1, comment);
00098 
00099 STANDARD_EXTERNAL(UnitTest)
00100 
00101 #endif   /* UNITTEST */  // -*-C++-*-

Home to blindfold. This page generated via doxygen 1.2.11.1 Wed Oct 10 16:40:33 2001.