Permalink
Browse files

Add support for 2 and 3 args in multi_test

  • Loading branch information...
1 parent 6b08843 commit d65748cb255e4f5c00d5bee2eaeab47552dfd4ec @thomasmoelhave committed Aug 2, 2012
Showing with 52 additions and 0 deletions.
  1. +52 −0 tpie/unittest.h
View
@@ -137,6 +137,17 @@ class tests {
template <typename T, typename T1>
tests & multi_test(T fct, const std::string & name, const std::string & p1_name, T1 p1_default);
+
+ template <typename T, typename T1, typename T2>
+ tests & multi_test(T fct, const std::string & name,
+ const std::string & p1_name, T1 p1_default,
+ const std::string & p2_name, T2 p2_default);
+
+ template <typename T, typename T1, typename T2, typename T3>
+ tests & multi_test(T fct, const std::string & name,
+ const std::string & p1_name, T1 p1_default,
+ const std::string & p2_name, T2 p2_default,
+ const std::string & p3_name, T3 p3_default);
operator int();
@@ -433,6 +444,47 @@ tests & tests::multi_test(T fct, const std::string & name, const std::string & p
return *this;
}
+template <typename T, typename T1, typename T2>
+tests & tests::multi_test(T fct, const std::string & name,
+ const std::string & p1_name, T1 p1_default,
+ const std::string & p2_name, T2 p2_default) {
+ m_tests.push_back(name+
+ arg_str(p1_name, p1_default) +
+ arg_str(p2_name, p2_default));
+
+ if (testAll || name == test_name) {
+ start_test(name);
+ teststream ts;
+ fct(ts,
+ get_arg(p1_name, p1_default),
+ get_arg(p2_name, p2_default));
+ end_test(ts.success());
+ }
+ return *this;
+}
+
+template <typename T, typename T1, typename T2, typename T3>
+tests & tests::multi_test(T fct, const std::string & name,
+ const std::string & p1_name, T1 p1_default,
+ const std::string & p2_name, T2 p2_default,
+ const std::string & p3_name, T3 p3_default) {
+ m_tests.push_back(name+
+ arg_str(p1_name, p1_default) +
+ arg_str(p2_name, p2_default) +
+ arg_str(p3_name, p3_default));
+
+ if (testAll || name == test_name) {
+ start_test(name);
+ teststream ts;
+ fct(ts,
+ get_arg(p1_name, p1_default),
+ get_arg(p2_name, p2_default),
+ get_arg(p3_name, p3_default));
+ end_test(ts.success());
+ }
+ return *this;
+}
+
template <typename T>
tests & tests::setup(T t) {
setups.push_back(new func_impl<T>(t));

0 comments on commit d65748c

Please sign in to comment.