]> git.tdb.fi Git - libs/test.git/blobdiff - source/function.h
Support passing a parameter to a test function
[libs/test.git] / source / function.h
index b76426ec2bf1df3735421f50ed81dd0f27a6bb18..a50b5c1d33252e5bae7159a82eae47f35c416af5 100644 (file)
@@ -39,7 +39,7 @@ private:
        FuncPtr func;
 
 public:
-       TypedFunction(FuncPtr f, const std::string & d):
+       TypedFunction(FuncPtr f, const std::string &d):
                Function(d),
                func(f)
        { }
@@ -50,6 +50,28 @@ public:
        }
 };
 
+template<typename T, typename A>
+class TypedFunction1: public Function
+{
+private:
+       typedef void (T::*FuncPtr)(A);
+
+       FuncPtr func;
+       A arg;
+
+public:
+       TypedFunction1(FuncPtr f, const A &a, const std::string &d):
+               Function(d),
+               func(f),
+               arg(a)
+       { }
+
+       virtual void run(Test &t) const
+       {
+               (dynamic_cast<T &>(t).*func)(arg);
+       }
+};
+
 } // namespace Test
 } // namespace Msp