Commits

Matt Oswald committed dae9a58

rewrote THEORY to define the theory, not the data set

Comments (0)

Files changed (2)

     Assert.Equal(0, 1);
 }
 
-void TestingTheory(int x, char y, bool equal)
+struct
+{
+    std::vector<std::tuple<int, char, bool>> operator()() const
+    {
+        auto result = std::vector<std::tuple<int, char, bool>>();
+        result.push_back(std::make_tuple(1, (char)1, true));
+        result.push_back(std::make_tuple(0, (char)1, false));
+        result.push_back(std::make_tuple(0, (char)1, true));
+        return result;
+    }
+} TestingTheoryDataProvider;
+
+THEORY(TestingNewTheory, (int x, char y, bool equal), TestingTheoryDataProvider)
 {
     if (equal)
     {
     }
 }
 
-THEORY(TestingTheory, int, char, bool)
-{
-    auto result = std::vector<std::tuple<int, char, bool>>();
-    result.push_back(std::make_tuple(1, (char)1, true));
-    result.push_back(std::make_tuple(0, (char)1, false));
-    result.push_back(std::make_tuple(0, (char)1, true));
-    return result;
-}
-
 struct MyFixture
 {
     MyFixture()
         Assert.Equal(0, 1);
     }
 
-    void SuiteTheory(int x, char y)
-    {
-        Assert.Equal(x, y);
-    }
-
-    THEORY(SuiteTheory, int, char)
+    std::vector<std::tuple<int, char>> SuiteTheoryDataProvider()
     {
         auto result = std::vector<std::tuple<int, char>>();
         result.push_back(std::make_tuple(1, (char)1));
         return result;
     }
 
+    THEORY(SuiteTheory, (int x, char y), SuiteTheoryDataProvider)
+    {
+        Assert.Equal(x, y);
+    }
+
     FACT_FIXTURE(SuiteFactFixture, MyFixture)
     {
         Assert.Equal(x, y - 1);

xUnit++/xUnitMacros.h

 
 #define FACT(FactName) TIMED_FACT(FactName, -1)
 
-#define TIMED_THEORY(TheoryName, timeout, ...) \
-    void TheoryName(__VA_ARGS__); \
-    std::vector<std::tuple<__VA_ARGS__>> TheoryName ## _data(); \
-    namespace TheoryName ## _ns { xUnitpp::TestCollection::Register reg(&TheoryName, &TheoryName ## _data, #TheoryName, xUnitSuite::Name(), timeout, __FILE__, __LINE__); } \
-    std::vector<std::tuple<__VA_ARGS__>> TheoryName ## _data()
+#define TIMED_THEORY(TheoryName, params, DataProvider, timeout) \
+    void TheoryName params; \
+    namespace TheoryName ## _ns { xUnitpp::TestCollection::Register reg(TheoryName, DataProvider, #TheoryName, xUnitSuite::Name(), timeout, __FILE__, __LINE__); } \
+    void TheoryName params
 
-#define THEORY(TheoryName, ...) TIMED_THEORY(TheoryName, -1, __VA_ARGS__)
+#define THEORY(TheoryName, params, DataProvider) TIMED_THEORY(TheoryName, params, DataProvider, -1)
 
 #define TIMED_FACT_FIXTURE(FactName, FixtureType, timeout) \
     namespace FactName ## _ns { \