implemented printing of the subcase stack
diff --git a/doc/markdown/features.md b/doc/markdown/features.md
index f996c0e..d628a9d 100644
--- a/doc/markdown/features.md
+++ b/doc/markdown/features.md
@@ -16,7 +16,7 @@
### Unintrusive (transparent):
- everything testing-related can be removed from the binary executable by defining the [**```DOCTEST_CONFIG_DISABLE```**](configuration.md) identifier
-- very small and easy to integrate - single header - less than 3k LOC in the implementation translation unit and less than 1k LOC everywhere else - **extremely** low footprint on compile times - see the [**benchmarks**](benchmarks.md)
+- very small and easy to integrate - single header - less than 3k LOC in the implementation translation unit and less than 1.5k LOC everywhere else - **extremely** low footprint on compile times - see the [**benchmarks**](benchmarks.md)
- doesn't drag any headers when included (except for in the translation unit where the library gets implemented)
- everything is in the ```doctest``` namespace (and the implementation details are in a nested ```detail``` namespace)
- all macros have prefixes - some by default have unprefixed versions as well but that is optional - see [**configuration**](configuration.md)
@@ -95,7 +95,7 @@
- add ```ERROR```/```FAIL``` macros
- running tests a few times
- marking a test to run X times (should also multiply with the global test run times)
-- test execution in separate processes - UNIX only with ```fork()``` (should also check out cygwin under windows)
+- test execution in separate processes - ```fork()``` for UNIX and [this](https://github.com/nemequ/munit/issues/2) for Windows
- ability to provide a temp folder that is cleared between each test case
- detect floating point exceptions
- ```Bitwise()``` class that has overloaded operators for comparison - to be used to check objects bitwise against each other
diff --git a/doctest/doctest.h b/doctest/doctest.h
index c20189b..429d568 100644
--- a/doctest/doctest.h
+++ b/doctest/doctest.h
@@ -713,6 +713,7 @@
// stuff for subcases
HashTable<Subcase> subcasesPassed;
HashTable<int> subcasesEnteredLevels;
+ Vector<Subcase> subcasesStack;
int subcasesCurrentLevel;
bool subcasesHasSkipped;
@@ -1632,6 +1633,11 @@
return;
}
+ s->subcasesStack.push_back(*this);
+ s->hasLoggedCurrentTestStart = false;
+ if(s->hasLoggedCurrentTestStart)
+ logTestEnd();
+
s->subcasesEnteredLevels.insert(s->subcasesCurrentLevel++);
m_entered = true;
}
@@ -1644,6 +1650,11 @@
// only mark the subcase as passed if no subcases have been skipped
if(s->subcasesHasSkipped == false)
s->subcasesPassed.insert(*this);
+
+ s->subcasesStack.pop_back();
+ s->hasLoggedCurrentTestStart = false;
+ if(s->hasLoggedCurrentTestStart)
+ logTestEnd();
}
}
@@ -1925,15 +1936,27 @@
DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)\n", fileForOutput(file), line);
char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), "test: \"%s\"\n", name);
+ DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), "%s\n", name);
DOCTEST_PRINTF_COLORED(getSeparator(), Color::Yellow);
DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
DOCTEST_PRINTF_COLORED(msg, Color::None);
- DOCTEST_PRINTF_COLORED(getSeparator(), Color::Yellow);
+
+ String subcaseStuff = "";
+ Vector<Subcase>& subcasesStack = DOCTEST_GCS()->subcasesStack;
+ String tabulation;
+ for(unsigned i = 0; i < subcasesStack.size(); ++i) {
+ tabulation += " ";
+ char subcase[DOCTEST_SNPRINTF_BUFFER_LENGTH];
+ DOCTEST_SNPRINTF(subcase, DOCTEST_COUNTOF(loc), "%s%s\n", tabulation.c_str(),
+ subcasesStack[i].m_name);
+ DOCTEST_PRINTF_COLORED(subcase, Color::None);
+ subcaseStuff += subcase;
+ }
+
DOCTEST_PRINTF_COLORED(newLine, Color::None);
- printToDebugConsole(String(getSeparator()) + loc + msg + getSeparator() + newLine);
+ printToDebugConsole(String(getSeparator()) + loc + msg + subcaseStuff.c_str() + newLine);
}
void logTestEnd() {}
@@ -2496,8 +2519,7 @@
//__try {
#endif // _MSC_VER
- p.currentTest = &data;
- p.hasLoggedCurrentTestStart = false;
+ p.currentTest = &data;
// if logging successful tests - force the start log
if(p.success) {
@@ -2508,6 +2530,8 @@
unsigned didFail = 0;
p.subcasesPassed.clear();
do {
+ p.hasLoggedCurrentTestStart = false;
+
// reset the assertion state
p.numAssertionsForCurrentTestcase = 0;
p.numFailedAssertionsForCurrentTestcase = 0;
@@ -2523,11 +2547,12 @@
// exit this loop if enough assertions have failed
if(p.abort_after > 0 && p.numFailedAssertions >= p.abort_after)
p.subcasesHasSkipped = false;
- } while(p.subcasesHasSkipped == true);
- // if the start has been logged
- if(p.hasLoggedCurrentTestStart)
- logTestEnd();
+ // if the start has been logged
+ if(p.hasLoggedCurrentTestStart)
+ logTestEnd();
+
+ } while(p.subcasesHasSkipped == true);
if(didFail > 0)
numFailed++;