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 #ifndef TESTHELPER_RUN_H
00026 #define TESTHELPER_RUN_H
00027
00028 #include "pre.hpp"
00029
00030
00031 #include "include/nobugcfg.h"
00032
00033 #include "lib/test/suite.hpp"
00034 #include "lib/util.hpp"
00035
00036 #include <vector>
00037 #include <string>
00038
00039
00040 namespace test
00041 {
00042
00043 using std::string;
00044 using std::auto_ptr;
00045
00046 typedef std::vector<string> & Arg;
00047
00048
00049
00054 class Test
00055 {
00056 public:
00057 virtual ~Test() {}
00058 virtual void run(Arg arg) = 0;
00059 };
00060
00061
00062
00064 class Launcher
00065 {
00066 public:
00067 virtual ~Launcher() {}
00068 virtual auto_ptr<Test> operator() () = 0;
00069 };
00070
00071
00083 template<class TEST>
00084 class Launch : public Launcher
00085 {
00086 public:
00087 Launch (string testID, string groups) { Suite::enroll (this,testID,groups); };
00088 virtual auto_ptr<Test> operator() () { return auto_ptr<Test> (new TEST ); };
00089 };
00090
00091 }
00092
00093
00094 using ::test::Arg;
00095 using ::test::Test;
00096 using ::test::Launch;
00097
00098
00099 #define LAUNCHER(_TEST_CLASS_, _GROUPS_) \
00100 \
00101 Launch<_TEST_CLASS_> run_##_TEST_CLASS_##_(STRINGIFY(_TEST_CLASS_), _GROUPS_);
00102
00103
00104 #endif