diff --git a/examples/JTest.h b/examples/JTest.h index f54135d..339e880 100644 --- a/examples/JTest.h +++ b/examples/JTest.h @@ -4,7 +4,7 @@ namespace JTest { using std::wostream; // TODO: Consider making testresults_t a class so we can hide the vectors behind accessor methods void add(...), T get(), vector get(uint32_t index) - typedef struct { + struct testresults_t { uint32_t total; uint32_t skipped; uint32_t passed; @@ -12,7 +12,18 @@ namespace JTest { // vector errors; // vector failures; // vector skipped; - } testresults_t; + }; + + testresults_t operator+(const testresults_t& left, const testresults_t& right); + testresults_t operator+(const testresults_t& left, const testresults_t& right) { + return add(left, right); + } + + testresults_t& operator+=(testresults_t& left, const testresults_t& right); + testresults_t& operator+=(testresults_t& left, const testresults_t& right) { + left = left + right; + return left; + } testresults_t make_testresults(); testresults_t make_testresults(uint32_t total, uint32_t skipped, uint32_t passed, uint32_t failed); diff --git a/examples/example.cpp b/examples/example.cpp index 2793af6..946dd3a 100644 --- a/examples/example.cpp +++ b/examples/example.cpp @@ -15,7 +15,28 @@ using std::wcout; // const vector& might stop being a reference testresults_t test_ClassToTest_main(int argc, const vector& argv) { - return make_testresults(); + auto results = describe(L"ClassToTest", [](){ + auto results = make_testresults(); + + results += it(L"should do the thing", [](){ + + }); + + results += it(L"should do the other thing", [](){ + + }); + + results += it(L"should not do the bad thing", [](){ + + }); + + results += it(L"should throw an exception if we do the other bad thing", [](){ + + }); + + return results; + }, make_describe_options().beforeEach([](){}).afterEach([](){}).beforeAll([](){}).afterAll([](){})); + return results; } // Dummy test harness