std::function<void(std::tuple<Args...> &t)> m_testFunc;
};
+typedef void(*TestFnType)();
+
+template<typename T>
+class TestCaseExt2 : public TestCase
+{
+public:
+ TestCaseExt2(const std::string &name, const TestFnType &testFunc)
+ : TestCase(name), m_testFunc(testFunc) {}
+
+private:
+ virtual void Init() { m_env.init(GetName()); }
+ virtual void Finish() { m_env.finish(); }
+ virtual void Test() { m_testFunc(); }
+
+ T m_env;
+ TestFnType m_testFunc;
+};
+
} // namespace Test
} // namespace DPL
TestResult::FailStatus TryCatch(const std::function<void(void)> &func, std::string &reason);
-}
+/*
+ * Test execution in multiple environments.
+ *
+ * To execute the same test in different environments provide an environment classes CLASS1, CLASS2,.... Classes have to
+ * provide init() & finish() methods to be called before and after execution in each environment.
+ * They should also provide suffix() method returning test case name suffix for given environment.
+ *
+ * Define the test as follows
+ *
+ * RUNNER_TEST_MULTIPLE(my_test, CLASS1, CLASS2,...)
+ * {
+ * // do the test stuff
+ * }
+ *
+ * For each class C the order of operation will be as follows:
+ * - construct C (default constructor)
+ * - call init() on C object
+ * - call test case function
+ * - call finish() on C object
+ * - destroy the C object
+ */
+
+template <typename ...Args>
+struct StaticProc;
+
+template <typename First>
+struct StaticProc<First> {
+protected:
+ static void Internal(const std::string& name, const TestFnType& proc) {
+ TestRunnerSingleton::Instance().RegisterTest(
+ new TestCaseExt2<First>(name + First::suffix(), proc));
+ }
+};
+
+template <typename First, typename ...Args>
+struct StaticProc<First, Args...> : public StaticProc<First>, public StaticProc<Args...> {
+ static int Init(const std::string& name, const TestFnType& proc) {
+ StaticProc<First, Args...>::Internal(name, proc);
+ return 0;
+ }
+protected:
+ static void Internal(const std::string& name, const TestFnType& proc) {
+ StaticProc<First>::Internal(name, proc);
+ StaticProc<Args...>::Internal(name, proc);
+ }
+};
+
+} // Test
} // namespace DPL
#define RUNNER_TEST_GROUP_INIT(GroupName) \
const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
void Proc(std::tuple<__VA_ARGS__> &optionalArgsTuple DPL_UNUSED)
+
+#define RUNNER_TEST_MULTIPLE(Proc, ...) \
+ void Proc(); \
+ const int DPL_UNUSED Static##Proc##InitVar = DPL::Test::StaticProc<__VA_ARGS__>::Init(#Proc, &Proc); \
+ void Proc()
+
/**
* ASSERT MACROS
*