module.hGo 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
00031 #ifndef KUNITTEST_MODULE_H
00032 #define KUNITTEST_MODULE_H
00033
00034 #include <qstring.h>
00035
00036 #include <klibloader.h>
00037 #include <kunittest/runner.h>
00038
00039 namespace KUnitTest
00040 {
00050 #define KUNITTEST_MODULE(library,suite) \
00051 static const QString s_kunittest_suite = QString::fromLatin1(suite); \
00052 class library##Module : public QObject \
00053 { \
00054 public: \
00055 library##Module() \
00056 { \
00057 KUnitTest::RegistryIteratorType it(s_registry); \
00058 for( ; it.current(); ++it ) \
00059 KUnitTest::Runner::registerTester(it.currentKey(), it.current()); \
00060 } \
00061 \
00062 static KUnitTest::RegistryType s_registry; \
00063 }; \
00064 \
00065 KUnitTest::RegistryType library##Module::s_registry; \
00066 \
00067 void kunittest_registerModuleTester(const char *name, KUnitTest::Tester *test) \
00068 { \
00069 library##Module::s_registry.insert(name, test); \
00070 } \
00071 \
00072 class module##Factory : public KLibFactory \
00073 { \
00074 public: \
00075 QObject *createObject (QObject *, const char *, const char *, const QStringList &) \
00076 { \
00077 return new library##Module(); \
00078 }; \
00079 }; \
00080 \
00081 K_EXPORT_COMPONENT_FACTORY( library, module##Factory )
00082
00089 #define KUNITTEST_MODULE_REGISTER_TESTER( tester) \
00090 static class tester##ModuleAutoregister \
00091 { \
00092 public: \
00093 tester##ModuleAutoregister() \
00094 { \
00095 KUnitTest::Tester *test = new tester(); \
00096 QString name = s_kunittest_suite + QString::fromLatin1("::") + QString::fromLocal8Bit(#tester); \
00097 test->setName(name.local8Bit()); \
00098 kunittest_registerModuleTester(name.local8Bit(), test ); \
00099 } \
00100 } tester##ModuleAutoregisterInstance;
00101
00107 #define KUNITTEST_MODULE_REGISTER_NAMEDTESTER( name , tester) \
00108 static class tester##ModuleAutoregister \
00109 { \
00110 public: \
00111 tester##ModuleAutoregister() \
00112 { \
00113 QString fullName = s_kunittest_suite + QString("::") + QString::fromLocal8Bit(name); \
00114 KUnitTest::Tester *test = new tester(fullName.local8Bit()); \
00115 kunittest_registerModuleTester(fullName.local8Bit(), test); \
00116 } \
00117 } tester##ModuleAutoregisterInstance;
00118 }
00119
00120 #endif
|