logog
logger optimized for games
unittest.hpp
Go to the documentation of this file.
1 
4 #ifndef __LOGOG_UNITTEST_HPP
5 #define __LOGOG_UNITTEST_HPP
6 
7 #include <iostream>
8 #include <string>
9 
10 namespace logog
11 {
12 
69 typedef const char * TestNameType;
70 class UnitTest;
71 
75 typedef LOGOG_LIST< UnitTest * > TestRegistryType;
76 
78 extern TestRegistryType &LogogTestRegistry();
79 
82 {
83 public:
85  TestSignup( UnitTest *pTest );
86 
87 protected:
90 private:
91  TestSignup();
92 };
93 
95 class UnitTest
96 {
97 public:
101  UnitTest( const TestNameType &sTestName );
102 
103  virtual ~UnitTest();
105  virtual TestNameType &GetName();
110  virtual int RunTest() = 0;
111 
118  virtual void FreeInternals();
119 
120 protected:
122  TestNameType m_sTestName;
125 private:
126  UnitTest();
127 };
128 
130 extern int RunAllTests();
131 
133 extern void ShutdownTests();
134 
138 #define UNITTEST( x ) class x : public UnitTest { \
139 public: \
140  x( TestNameType name ) : \
141  UnitTest( name ) \
142  {} \
143  virtual ~x() {}; \
144  virtual int RunTest(); \
145  }; \
146  x __LogogTestInstance_ ## x ( #x ); \
147  int x::RunTest()
148 
149 }
150 
151 #endif // __LOGOG_UNITTEST_HPP
virtual void FreeInternals()
[Thread]
Definition: api.hpp:8
virtual ~UnitTest()
const char * TestNameType
Definition: unittest.hpp:69
TestRegistryType & LogogTestRegistry()
Definition: unittest.hpp:81
TestSignup * m_pTestSignup
Definition: unittest.hpp:124
UnitTest * m_pTest
Definition: unittest.hpp:89
TestNameType m_sTestName
Definition: unittest.hpp:122
int RunAllTests()
virtual int RunTest()=0
void ShutdownTests()
virtual TestNameType & GetName()
LOGOG_LIST< UnitTest * > TestRegistryType
Definition: unittest.hpp:70
Definition: unittest.hpp:95