Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print subcase stack upon a subcase entry
This is largely a hack to give us at least *something* for data driven testing (doctest#215). In that pattern, it's common to structure code in a way that first "generates the data", and only then executes the actual test. It can look like this: TEST_CASE("parsing stuff") { std::string input; Something expected; DOCTEST_SUBCASE("single-line") { DOCTEST_SUBCASE("empty") {} DOCTEST_SUBCASE("trivial") { input = "create foo"; expected = {OP_CREATE, {"foo",}}; } DOCTEST_SUBCASE("two args") { input = "create blah bar"; expected = {OP_CREATE, {"blah", "bar",}}; } } DOCTEST_SUBCASE("multi-line") { DOCTEST_SUBCASE("trailing whitespace") { input = "create foo\n\n"; expected = {OP_CREATE, {"foo,}}; } DOCTEST_SUBCASE("one word per line, two words") { input = "create\nfoo"; expected = {OP_CREATE, {"foo",}}; } } REQUIRE(parse(input) == expected); } The important part is that once we're executing actual tests, the subsections will have been exited already, so the usual ways of showing the subcase stack can be no longer applied. In Catch2, there was a patch which tried to track the deepest subcase stack so far. Let's try to implement something very simple, just printing the current state of the stack once it is entered. It does not tie into any error handling, so the output will be always there, and it also probably does not support any fancy filtering when skipping subcases. However, it's something which at least shows what is going on when an error gets reported. Cc: doctest#215 Cc: doctest#125
- Loading branch information