Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/onqtam/doctest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/markdown/roadmap.md27
-rw-r--r--doctest/doctest.h135
-rw-r--r--doctest/parts/doctest_fwd.h13
-rw-r--r--doctest/parts/doctest_impl.h122
-rw-r--r--examples/all_features/test_output/abort_after.txt1
-rw-r--r--examples/all_features/test_output/all_binary.txt1
-rw-r--r--examples/all_features/test_output/alternative_macros.cpp.txt1
-rw-r--r--examples/all_features/test_output/assertion_macros.cpp.txt1
-rw-r--r--examples/all_features/test_output/coverage_maxout.cpp.txt1
-rw-r--r--examples/all_features/test_output/doctest_proxy.h.txt1
-rw-r--r--examples/all_features/test_output/filter_1.txt1
-rw-r--r--examples/all_features/test_output/filter_2.txt1
-rw-r--r--examples/all_features/test_output/filter_3.txt1
-rw-r--r--examples/all_features/test_output/first_last.txt1
-rw-r--r--examples/all_features/test_output/header.h.txt3
-rw-r--r--examples/all_features/test_output/logging.cpp.txt3
-rw-r--r--examples/all_features/test_output/main.cpp.txt1
-rw-r--r--examples/all_features/test_output/order_1.txt3
-rw-r--r--examples/all_features/test_output/order_2.txt3
-rw-r--r--examples/all_features/test_output/order_3.txt1
-rw-r--r--examples/all_features/test_output/stringification.cpp.txt1
-rw-r--r--examples/all_features/test_output/subcases.cpp.txt3
-rw-r--r--examples/all_features/test_output/templated_test_cases.cpp.txt1
-rw-r--r--examples/all_features/test_output/test_cases_and_suites.cpp.txt3
-rw-r--r--examples/exe_with_static_libs/test_output/exe_with_static_libs.txt1
-rw-r--r--examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt1
-rw-r--r--scripts/playground/test.cpp75
-rw-r--r--scripts/playground/test_output/playground.txt36
28 files changed, 285 insertions, 157 deletions
diff --git a/doc/markdown/roadmap.md b/doc/markdown/roadmap.md
index 2d5c8ae2..45e9dff1 100644
--- a/doc/markdown/roadmap.md
+++ b/doc/markdown/roadmap.md
@@ -12,17 +12,15 @@ Planned features for future releases - order changes constantly...
- decorators
- test_suite
- - description can inherit from test suites
- - disabled (skip) can inherit from test suites
- - enable_if (skip_if) can inherit from test suites
- - mayfail - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in the your tests.
- - shouldfail - like [!mayfail] but fails the test if it passes. This can be useful if you want to be notified of accidental, or third-party, fixes.
- - expected_failures (decorator)
- - label (tag) can inherit from test suites
- - !!! and think about how these will be accessed and filtered from the command line
+ - description
+ - skip
+ - may_fail - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in the your tests.
+ - should_fail - like [!mayfail] but fails the test if it passes. This can be useful if you want to be notified of accidental, or third-party, fixes.
+ - expected_failures
+ - label (tag)
- time stuff
- reporting running time of tests
- - timeout (decorator) can inherit from test suites
+ - timeout (decorator)
- count a test case as failed if it exceeds X ms (but no force-killing!)
Entering test module "decorator_08"
test.cpp(6): Entering test case "test1"
@@ -50,6 +48,7 @@ Planned features for future releases - order changes constantly...
- https://github.com/rollbear/trompeloeil
- https://github.com/dascandy/hippomocks
- benchmarking
+ - remove catch as a submodule - fetch it by normal downloading
- make the bench.py script more usable - with command line arguments
- redo the compile time ones - also look into CATCH_CONFIG_FAST_COMPILE
- remove old benchmarks for doctest 1.0
@@ -155,10 +154,11 @@ Planned features for future releases - order changes constantly...
- option to list test suites and test cases in a tree view
- add a "wait key" option - as requested [here](https://github.com/philsquared/Catch/issues/477#issuecomment-256417686)
- decorators for test cases and test suites- like in boost test
- - depends_on (decorator)
- - precondition (decorator)
- - fixture (decorator)
+ - depends_on
+ - precondition
+ - fixture
- run X times (should also multiply with (or just override) the global test run times)
+ - throw an exception when incompatible decorators are given in the same list of decorators - like may_fail and should_fail
- setup / teardown support
- global setup / teardown - can be currently achieved by providing a custom main function
- per test suite (block? only? and not all blocks of the same test suite?)
@@ -184,7 +184,8 @@ Planned features for future releases - order changes constantly...
- test with missed warning flags for GCC
- https://github.com/Barro/compiler-warnings
- http://stackoverflow.com/a/34971392/3162383
-- utf8???
+- utf8 / unicode ???
+ - https://github.com/philsquared/Catch/pull/903
- handle ```wchar``` strings???
- hierarchical test suites - using a stack for the pushed ones
- ability to specify the width of the terminal in terms of characters (for example 60 - less than 80 - the default)
diff --git a/doctest/doctest.h b/doctest/doctest.h
index 2d0258b1..d758503f 100644
--- a/doctest/doctest.h
+++ b/doctest/doctest.h
@@ -1836,6 +1836,7 @@ struct test_suite
test_suite(const char* in)
: data(in) {}
void fill(detail::TestCase& state) const { state.m_test_suite = data; }
+ void fill(detail::TestSuite& state) const { state.m_test_suite = data; }
};
struct description
@@ -1849,14 +1850,8 @@ struct description
struct skip
{
- void fill(detail::TestCase& state) const { state.m_skip = true; }
- void fill(detail::TestSuite& state) const { state.m_skip = true; }
-};
-
-struct skip_if
-{
bool data;
- skip_if(bool in)
+ skip(bool in = true)
: data(in) {}
void fill(detail::TestCase& state) const { state.m_skip = data; }
void fill(detail::TestSuite& state) const { state.m_skip = data; }
@@ -1865,7 +1860,7 @@ struct skip_if
struct may_fail
{
bool data;
- may_fail(bool in)
+ may_fail(bool in = true)
: data(in) {}
void fill(detail::TestCase& state) const { state.m_may_fail = data; }
void fill(detail::TestSuite& state) const { state.m_may_fail = data; }
@@ -1874,7 +1869,7 @@ struct may_fail
struct should_fail
{
bool data;
- should_fail(bool in)
+ should_fail(bool in = true)
: data(in) {}
void fill(detail::TestCase& state) const { state.m_should_fail = data; }
void fill(detail::TestSuite& state) const { state.m_should_fail = data; }
@@ -3276,6 +3271,7 @@ namespace detail
bool hasLoggedCurrentTestStart;
int numAssertionsForCurrentTestcase;
int numAssertions;
+ int numFailedAssertionsForCurrentTestcase;
int numFailedAssertions;
bool hasCurrentTestFailed;
@@ -3290,11 +3286,12 @@ namespace detail
bool subcasesHasSkipped;
void resetRunData() {
- numTestsPassingFilters = 0;
- numTestSuitesPassingFilters = 0;
- numFailed = 0;
- numAssertions = 0;
- numFailedAssertions = 0;
+ numTestsPassingFilters = 0;
+ numTestSuitesPassingFilters = 0;
+ numFailed = 0;
+ numAssertions = 0;
+ numFailedAssertions = 0;
+ numFailedAssertionsForCurrentTestcase = 0;
}
// cppcheck-suppress uninitMemberVar
@@ -4309,8 +4306,9 @@ namespace detail
void addFailedAssert(assertType::Enum assert_type) {
if((assert_type & assertType::is_warn) == 0) {
- getContextState()->hasCurrentTestFailed = true;
getContextState()->numFailedAssertions++;
+ getContextState()->numFailedAssertionsForCurrentTestcase++;
+ getContextState()->hasCurrentTestFailed = true;
}
}
@@ -4672,33 +4670,34 @@ namespace detail
bool is_warn = m_severity & doctest::detail::assertType::is_warn;
- if(!is_warn)
- getContextState()->hasCurrentTestFailed = true;
+ // warn is just a message in this context so we dont treat it as an assert
+ if(!is_warn) {
+ DOCTEST_GCS().numAssertionsForCurrentTestcase++;
+ addFailedAssert(m_severity);
+ }
- {
- char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)", fileForOutput(m_file),
- lineForOutput(m_line));
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), " %s!\n",
- is_warn ? "MESSAGE" : getFailString(m_severity));
-
- DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
- DOCTEST_PRINTF_COLORED(msg, is_warn ? Color::Yellow : Color::Red);
-
- String info = getStreamResult(m_stream);
- if(info.length()) {
- DOCTEST_PRINTF_COLORED(" ", Color::None);
- DOCTEST_PRINTF_COLORED(info.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
- }
- String context = logContext();
- DOCTEST_PRINTF_COLORED(context.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
+ char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
+ DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)", fileForOutput(m_file),
+ lineForOutput(m_line));
+ char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
+ DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), " %s!\n",
+ is_warn ? "MESSAGE" : getFailString(m_severity));
+
+ DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
+ DOCTEST_PRINTF_COLORED(msg, is_warn ? Color::Yellow : Color::Red);
- printToDebugConsole(String(loc) + msg + " " + info.c_str() + "\n" + context.c_str() +
- "\n");
+ String info = getStreamResult(m_stream);
+ if(info.length()) {
+ DOCTEST_PRINTF_COLORED(" ", Color::None);
+ DOCTEST_PRINTF_COLORED(info.c_str(), Color::None);
+ DOCTEST_PRINTF_COLORED("\n", Color::None);
}
+ String context = logContext();
+ DOCTEST_PRINTF_COLORED(context.c_str(), Color::None);
+ DOCTEST_PRINTF_COLORED("\n", Color::None);
+
+ printToDebugConsole(String(loc) + msg + " " + info.c_str() + "\n" + context.c_str() +
+ "\n");
return isDebuggerActive() && !DOCTEST_GCS().no_breaks && !is_warn; // break into debugger
}
@@ -4929,6 +4928,8 @@ namespace detail
std::printf("test suites with unskipped test cases passing the current filters: %u\n",
p->numTestSuitesPassingFilters);
} else {
+ bool anythingFailed = p->numFailed > 0 || p->numFailedAssertions > 0;
+
char buff[DOCTEST_SNPRINTF_BUFFER_LENGTH];
DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
@@ -4940,7 +4941,10 @@ namespace detail
DOCTEST_PRINTF_COLORED(buff, Color::None);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d passed",
p->numTestsPassingFilters - p->numFailed);
- DOCTEST_PRINTF_COLORED(buff, p->numFailed > 0 ? Color::None : Color::Green);
+ DOCTEST_PRINTF_COLORED(buff,
+ (p->numTestsPassingFilters == 0 || anythingFailed) ?
+ Color::None :
+ Color::Green);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
DOCTEST_PRINTF_COLORED(buff, Color::None);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4u failed", p->numFailed);
@@ -4949,10 +4953,10 @@ namespace detail
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
DOCTEST_PRINTF_COLORED(buff, Color::None);
if(p->no_skipped_summary == false) {
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d skipped",
- static_cast<unsigned>(getRegisteredTests().size()) -
- p->numTestsPassingFilters);
- DOCTEST_PRINTF_COLORED(buff, Color::None);
+ int numSkipped = static_cast<unsigned>(getRegisteredTests().size()) -
+ p->numTestsPassingFilters;
+ DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d skipped", numSkipped);
+ DOCTEST_PRINTF_COLORED(buff, numSkipped == 0 ? Color::None : Color::Yellow);
}
DOCTEST_PRINTF_COLORED("\n", Color::None);
@@ -4964,7 +4968,8 @@ namespace detail
DOCTEST_PRINTF_COLORED(buff, Color::None);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d passed",
p->numAssertions - p->numFailedAssertions);
- DOCTEST_PRINTF_COLORED(buff, p->numFailed > 0 ? Color::None : Color::Green);
+ DOCTEST_PRINTF_COLORED(
+ buff, (p->numAssertions == 0 || anythingFailed) ? Color::None : Color::Green);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
DOCTEST_PRINTF_COLORED(buff, Color::None);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d failed", p->numFailedAssertions);
@@ -4972,6 +4977,11 @@ namespace detail
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " |\n");
DOCTEST_PRINTF_COLORED(buff, Color::None);
+
+ DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
+ DOCTEST_PRINTF_COLORED("Status: ", Color::None);
+ const char* result = (p->numFailed > 0) ? "FAILURE!\n" : "SUCCESS!\n";
+ DOCTEST_PRINTF_COLORED(result, p->numFailed > 0 ? Color::Red : Color::Green);
}
// remove any coloring
@@ -5248,7 +5258,8 @@ int Context::run() {
if(p->success)
DOCTEST_LOG_START();
- bool failed = false;
+ bool failed = false;
+ p->numFailedAssertionsForCurrentTestcase = 0;
p->subcasesPassed.clear();
do {
// reset the assertion state
@@ -5295,6 +5306,38 @@ int Context::run() {
} while(p->subcasesHasSkipped == true);
+ if(data.m_should_fail) {
+ if(!failed) {
+ failed = true;
+ DOCTEST_PRINTF_COLORED("Should have failed but didn't! Marking it as failed!\n",
+ Color::Red);
+ } else {
+ failed = false;
+ }
+ } else if(failed && data.m_may_fail) {
+ failed = false;
+ DOCTEST_PRINTF_COLORED("Allowed to fail so marking it as not failed\n",
+ Color::Yellow);
+ } else if(data.m_expected_failures > 0) {
+ char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
+ if(p->numFailedAssertionsForCurrentTestcase == data.m_expected_failures) {
+ failed = false;
+ DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg),
+ "Failed exactly %d times so marking it as not failed!\n",
+ data.m_expected_failures);
+ DOCTEST_PRINTF_COLORED(msg, Color::Yellow);
+ } else {
+ //DOCTEST_LOG_START();
+ failed = true;
+ DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg),
+ "Didn't fail exactly %d times so marking it as failed!\n",
+ data.m_expected_failures);
+ DOCTEST_PRINTF_COLORED(msg, Color::Red);
+ }
+ }
+
+ //if(failed &&
+
if(failed) // if any subcase has failed - the whole test case has failed
p->numFailed++;
diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h
index c004b803..d416f158 100644
--- a/doctest/parts/doctest_fwd.h
+++ b/doctest/parts/doctest_fwd.h
@@ -1833,6 +1833,7 @@ struct test_suite
test_suite(const char* in)
: data(in) {}
void fill(detail::TestCase& state) const { state.m_test_suite = data; }
+ void fill(detail::TestSuite& state) const { state.m_test_suite = data; }
};
struct description
@@ -1846,14 +1847,8 @@ struct description
struct skip
{
- void fill(detail::TestCase& state) const { state.m_skip = true; }
- void fill(detail::TestSuite& state) const { state.m_skip = true; }
-};
-
-struct skip_if
-{
bool data;
- skip_if(bool in)
+ skip(bool in = true)
: data(in) {}
void fill(detail::TestCase& state) const { state.m_skip = data; }
void fill(detail::TestSuite& state) const { state.m_skip = data; }
@@ -1862,7 +1857,7 @@ struct skip_if
struct may_fail
{
bool data;
- may_fail(bool in)
+ may_fail(bool in = true)
: data(in) {}
void fill(detail::TestCase& state) const { state.m_may_fail = data; }
void fill(detail::TestSuite& state) const { state.m_may_fail = data; }
@@ -1871,7 +1866,7 @@ struct may_fail
struct should_fail
{
bool data;
- should_fail(bool in)
+ should_fail(bool in = true)
: data(in) {}
void fill(detail::TestCase& state) const { state.m_should_fail = data; }
void fill(detail::TestSuite& state) const { state.m_should_fail = data; }
diff --git a/doctest/parts/doctest_impl.h b/doctest/parts/doctest_impl.h
index 4ded8669..d2c0f165 100644
--- a/doctest/parts/doctest_impl.h
+++ b/doctest/parts/doctest_impl.h
@@ -242,6 +242,7 @@ namespace detail
bool hasLoggedCurrentTestStart;
int numAssertionsForCurrentTestcase;
int numAssertions;
+ int numFailedAssertionsForCurrentTestcase;
int numFailedAssertions;
bool hasCurrentTestFailed;
@@ -256,11 +257,12 @@ namespace detail
bool subcasesHasSkipped;
void resetRunData() {
- numTestsPassingFilters = 0;
- numTestSuitesPassingFilters = 0;
- numFailed = 0;
- numAssertions = 0;
- numFailedAssertions = 0;
+ numTestsPassingFilters = 0;
+ numTestSuitesPassingFilters = 0;
+ numFailed = 0;
+ numAssertions = 0;
+ numFailedAssertions = 0;
+ numFailedAssertionsForCurrentTestcase = 0;
}
// cppcheck-suppress uninitMemberVar
@@ -1275,8 +1277,9 @@ namespace detail
void addFailedAssert(assertType::Enum assert_type) {
if((assert_type & assertType::is_warn) == 0) {
- getContextState()->hasCurrentTestFailed = true;
getContextState()->numFailedAssertions++;
+ getContextState()->numFailedAssertionsForCurrentTestcase++;
+ getContextState()->hasCurrentTestFailed = true;
}
}
@@ -1638,33 +1641,34 @@ namespace detail
bool is_warn = m_severity & doctest::detail::assertType::is_warn;
- if(!is_warn)
- getContextState()->hasCurrentTestFailed = true;
+ // warn is just a message in this context so we dont treat it as an assert
+ if(!is_warn) {
+ DOCTEST_GCS().numAssertionsForCurrentTestcase++;
+ addFailedAssert(m_severity);
+ }
- {
- char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)", fileForOutput(m_file),
- lineForOutput(m_line));
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), " %s!\n",
- is_warn ? "MESSAGE" : getFailString(m_severity));
-
- DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
- DOCTEST_PRINTF_COLORED(msg, is_warn ? Color::Yellow : Color::Red);
-
- String info = getStreamResult(m_stream);
- if(info.length()) {
- DOCTEST_PRINTF_COLORED(" ", Color::None);
- DOCTEST_PRINTF_COLORED(info.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
- }
- String context = logContext();
- DOCTEST_PRINTF_COLORED(context.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
+ char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
+ DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)", fileForOutput(m_file),
+ lineForOutput(m_line));
+ char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
+ DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), " %s!\n",
+ is_warn ? "MESSAGE" : getFailString(m_severity));
- printToDebugConsole(String(loc) + msg + " " + info.c_str() + "\n" + context.c_str() +
- "\n");
+ DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
+ DOCTEST_PRINTF_COLORED(msg, is_warn ? Color::Yellow : Color::Red);
+
+ String info = getStreamResult(m_stream);
+ if(info.length()) {
+ DOCTEST_PRINTF_COLORED(" ", Color::None);
+ DOCTEST_PRINTF_COLORED(info.c_str(), Color::None);
+ DOCTEST_PRINTF_COLORED("\n", Color::None);
}
+ String context = logContext();
+ DOCTEST_PRINTF_COLORED(context.c_str(), Color::None);
+ DOCTEST_PRINTF_COLORED("\n", Color::None);
+
+ printToDebugConsole(String(loc) + msg + " " + info.c_str() + "\n" + context.c_str() +
+ "\n");
return isDebuggerActive() && !DOCTEST_GCS().no_breaks && !is_warn; // break into debugger
}
@@ -1895,6 +1899,8 @@ namespace detail
std::printf("test suites with unskipped test cases passing the current filters: %u\n",
p->numTestSuitesPassingFilters);
} else {
+ bool anythingFailed = p->numFailed > 0 || p->numFailedAssertions > 0;
+
char buff[DOCTEST_SNPRINTF_BUFFER_LENGTH];
DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
@@ -1906,7 +1912,10 @@ namespace detail
DOCTEST_PRINTF_COLORED(buff, Color::None);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d passed",
p->numTestsPassingFilters - p->numFailed);
- DOCTEST_PRINTF_COLORED(buff, p->numFailed > 0 ? Color::None : Color::Green);
+ DOCTEST_PRINTF_COLORED(buff,
+ (p->numTestsPassingFilters == 0 || anythingFailed) ?
+ Color::None :
+ Color::Green);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
DOCTEST_PRINTF_COLORED(buff, Color::None);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4u failed", p->numFailed);
@@ -1915,10 +1924,10 @@ namespace detail
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
DOCTEST_PRINTF_COLORED(buff, Color::None);
if(p->no_skipped_summary == false) {
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d skipped",
- static_cast<unsigned>(getRegisteredTests().size()) -
- p->numTestsPassingFilters);
- DOCTEST_PRINTF_COLORED(buff, Color::None);
+ int numSkipped = static_cast<unsigned>(getRegisteredTests().size()) -
+ p->numTestsPassingFilters;
+ DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d skipped", numSkipped);
+ DOCTEST_PRINTF_COLORED(buff, numSkipped == 0 ? Color::None : Color::Yellow);
}
DOCTEST_PRINTF_COLORED("\n", Color::None);
@@ -1930,7 +1939,8 @@ namespace detail
DOCTEST_PRINTF_COLORED(buff, Color::None);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d passed",
p->numAssertions - p->numFailedAssertions);
- DOCTEST_PRINTF_COLORED(buff, p->numFailed > 0 ? Color::None : Color::Green);
+ DOCTEST_PRINTF_COLORED(
+ buff, (p->numAssertions == 0 || anythingFailed) ? Color::None : Color::Green);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
DOCTEST_PRINTF_COLORED(buff, Color::None);
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%4d failed", p->numFailedAssertions);
@@ -1938,6 +1948,11 @@ namespace detail
DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " |\n");
DOCTEST_PRINTF_COLORED(buff, Color::None);
+
+ DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
+ DOCTEST_PRINTF_COLORED("Status: ", Color::None);
+ const char* result = (p->numFailed > 0) ? "FAILURE!\n" : "SUCCESS!\n";
+ DOCTEST_PRINTF_COLORED(result, p->numFailed > 0 ? Color::Red : Color::Green);
}
// remove any coloring
@@ -2214,7 +2229,8 @@ int Context::run() {
if(p->success)
DOCTEST_LOG_START();
- bool failed = false;
+ bool failed = false;
+ p->numFailedAssertionsForCurrentTestcase = 0;
p->subcasesPassed.clear();
do {
// reset the assertion state
@@ -2261,6 +2277,38 @@ int Context::run() {
} while(p->subcasesHasSkipped == true);
+ if(data.m_should_fail) {
+ if(!failed) {
+ failed = true;
+ DOCTEST_PRINTF_COLORED("Should have failed but didn't! Marking it as failed!\n",
+ Color::Red);
+ } else {
+ failed = false;
+ }
+ } else if(failed && data.m_may_fail) {
+ failed = false;
+ DOCTEST_PRINTF_COLORED("Allowed to fail so marking it as not failed\n",
+ Color::Yellow);
+ } else if(data.m_expected_failures > 0) {
+ char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
+ if(p->numFailedAssertionsForCurrentTestcase == data.m_expected_failures) {
+ failed = false;
+ DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg),
+ "Failed exactly %d times so marking it as not failed!\n",
+ data.m_expected_failures);
+ DOCTEST_PRINTF_COLORED(msg, Color::Yellow);
+ } else {
+ //DOCTEST_LOG_START();
+ failed = true;
+ DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg),
+ "Didn't fail exactly %d times so marking it as failed!\n",
+ data.m_expected_failures);
+ DOCTEST_PRINTF_COLORED(msg, Color::Red);
+ }
+ }
+
+ //if(failed &&
+
if(failed) // if any subcase has failed - the whole test case has failed
p->numFailed++;
diff --git a/examples/all_features/test_output/abort_after.txt b/examples/all_features/test_output/abort_after.txt
index 3a86876f..de53207a 100644
--- a/examples/all_features/test_output/abort_after.txt
+++ b/examples/all_features/test_output/abort_after.txt
@@ -21,4 +21,5 @@ Aborting - too many failed asserts!
===============================================================================
[doctest] test cases: 1 | 0 passed | 1 failed |
[doctest] assertions: 6 | 4 passed | 2 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/all_binary.txt b/examples/all_features/test_output/all_binary.txt
index 19eb8b2c..15c20126 100644
--- a/examples/all_features/test_output/all_binary.txt
+++ b/examples/all_features/test_output/all_binary.txt
@@ -246,4 +246,5 @@ with expansion:
===============================================================================
[doctest] test cases: 1 | 1 passed | 0 failed |
[doctest] assertions: 32 | 32 passed | 0 failed |
+[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/alternative_macros.cpp.txt b/examples/all_features/test_output/alternative_macros.cpp.txt
index e20c8f43..56b5630a 100644
--- a/examples/all_features/test_output/alternative_macros.cpp.txt
+++ b/examples/all_features/test_output/alternative_macros.cpp.txt
@@ -2,4 +2,5 @@
===============================================================================
[doctest] test cases: 1 | 1 passed | 0 failed |
[doctest] assertions: 6 | 6 passed | 0 failed |
+[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/assertion_macros.cpp.txt b/examples/all_features/test_output/assertion_macros.cpp.txt
index 15855798..87ac5b57 100644
--- a/examples/all_features/test_output/assertion_macros.cpp.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp.txt
@@ -293,4 +293,5 @@ with expansion:
===============================================================================
[doctest] test cases: 20 | 4 passed | 16 failed |
[doctest] assertions: 88 | 54 passed | 34 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/coverage_maxout.cpp.txt b/examples/all_features/test_output/coverage_maxout.cpp.txt
index 1ecf30cb..404dce79 100644
--- a/examples/all_features/test_output/coverage_maxout.cpp.txt
+++ b/examples/all_features/test_output/coverage_maxout.cpp.txt
@@ -54,4 +54,5 @@ threw exception:
===============================================================================
[doctest] test cases: 4 | 0 passed | 4 failed |
[doctest] assertions: 7 | 4 passed | 3 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/doctest_proxy.h.txt b/examples/all_features/test_output/doctest_proxy.h.txt
index eca69f05..ac2cbe4a 100644
--- a/examples/all_features/test_output/doctest_proxy.h.txt
+++ b/examples/all_features/test_output/doctest_proxy.h.txt
@@ -2,4 +2,5 @@
===============================================================================
[doctest] test cases: 0 | 0 passed | 0 failed |
[doctest] assertions: 0 | 0 passed | 0 failed |
+[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/filter_1.txt b/examples/all_features/test_output/filter_1.txt
index eca69f05..ac2cbe4a 100644
--- a/examples/all_features/test_output/filter_1.txt
+++ b/examples/all_features/test_output/filter_1.txt
@@ -2,4 +2,5 @@
===============================================================================
[doctest] test cases: 0 | 0 passed | 0 failed |
[doctest] assertions: 0 | 0 passed | 0 failed |
+[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/filter_2.txt b/examples/all_features/test_output/filter_2.txt
index 286c9ed3..47d75dcd 100644
--- a/examples/all_features/test_output/filter_2.txt
+++ b/examples/all_features/test_output/filter_2.txt
@@ -2,4 +2,5 @@
===============================================================================
[doctest] test cases: 0 | 0 passed | 0 failed | 62 skipped
[doctest] assertions: 0 | 0 passed | 0 failed |
+[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/filter_3.txt b/examples/all_features/test_output/filter_3.txt
index b72573df..4080dc03 100644
--- a/examples/all_features/test_output/filter_3.txt
+++ b/examples/all_features/test_output/filter_3.txt
@@ -21,4 +21,5 @@ subcases.cpp(0) MESSAGE!
===============================================================================
[doctest] test cases: 3 | 3 passed | 0 failed |
[doctest] assertions: 0 | 0 passed | 0 failed |
+[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/first_last.txt b/examples/all_features/test_output/first_last.txt
index 5f64c78e..a7027b63 100644
--- a/examples/all_features/test_output/first_last.txt
+++ b/examples/all_features/test_output/first_last.txt
@@ -29,4 +29,5 @@ threw exception:
===============================================================================
[doctest] test cases: 4 | 1 passed | 3 failed |
[doctest] assertions: 0 | 0 passed | 0 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/header.h.txt b/examples/all_features/test_output/header.h.txt
index dd798247..5a26a5b5 100644
--- a/examples/all_features/test_output/header.h.txt
+++ b/examples/all_features/test_output/header.h.txt
@@ -20,5 +20,6 @@ header.h(0) FATAL ERROR!
===============================================================================
[doctest] test cases: 4 | 1 passed | 3 failed |
-[doctest] assertions: 1 | 1 passed | 0 failed |
+[doctest] assertions: 4 | 1 passed | 3 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/logging.cpp.txt b/examples/all_features/test_output/logging.cpp.txt
index 2fe5fce9..5cc1fc43 100644
--- a/examples/all_features/test_output/logging.cpp.txt
+++ b/examples/all_features/test_output/logging.cpp.txt
@@ -105,5 +105,6 @@ logging.cpp(0) FATAL ERROR!
===============================================================================
[doctest] test cases: 6 | 0 passed | 6 failed |
-[doctest] assertions: 6 | 0 passed | 6 failed |
+[doctest] assertions: 11 | 0 passed | 11 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/main.cpp.txt b/examples/all_features/test_output/main.cpp.txt
index ef42e866..302badae 100644
--- a/examples/all_features/test_output/main.cpp.txt
+++ b/examples/all_features/test_output/main.cpp.txt
@@ -2,4 +2,5 @@
===============================================================================
[doctest] test cases: 1 | 1 passed | 0 failed |
[doctest] assertions: 1 | 1 passed | 0 failed |
+[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/order_1.txt b/examples/all_features/test_output/order_1.txt
index 9f306699..9d8ed15b 100644
--- a/examples/all_features/test_output/order_1.txt
+++ b/examples/all_features/test_output/order_1.txt
@@ -39,5 +39,6 @@ test_cases_and_suites.cpp(0) FATAL ERROR!
===============================================================================
[doctest] test cases: 6 | 1 passed | 5 failed |
-[doctest] assertions: 2 | 1 passed | 1 failed |
+[doctest] assertions: 5 | 1 passed | 4 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/order_2.txt b/examples/all_features/test_output/order_2.txt
index 8df1a21e..5055d2f4 100644
--- a/examples/all_features/test_output/order_2.txt
+++ b/examples/all_features/test_output/order_2.txt
@@ -39,5 +39,6 @@ threw exception:
===============================================================================
[doctest] test cases: 6 | 1 passed | 5 failed |
-[doctest] assertions: 2 | 1 passed | 1 failed |
+[doctest] assertions: 5 | 1 passed | 4 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/order_3.txt b/examples/all_features/test_output/order_3.txt
index eca69f05..ac2cbe4a 100644
--- a/examples/all_features/test_output/order_3.txt
+++ b/examples/all_features/test_output/order_3.txt
@@ -2,4 +2,5 @@
===============================================================================
[doctest] test cases: 0 | 0 passed | 0 failed |
[doctest] assertions: 0 | 0 passed | 0 failed |
+[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/stringification.cpp.txt b/examples/all_features/test_output/stringification.cpp.txt
index 4a8fb040..1305b3c7 100644
--- a/examples/all_features/test_output/stringification.cpp.txt
+++ b/examples/all_features/test_output/stringification.cpp.txt
@@ -38,4 +38,5 @@ threw exception:
===============================================================================
[doctest] test cases: 2 | 0 passed | 2 failed |
[doctest] assertions: 4 | 0 passed | 4 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/subcases.cpp.txt b/examples/all_features/test_output/subcases.cpp.txt
index 5701ddda..92d4082c 100644
--- a/examples/all_features/test_output/subcases.cpp.txt
+++ b/examples/all_features/test_output/subcases.cpp.txt
@@ -76,5 +76,6 @@ with expansion:
===============================================================================
[doctest] test cases: 3 | 1 passed | 2 failed |
-[doctest] assertions: 16 | 14 passed | 2 failed |
+[doctest] assertions: 17 | 14 passed | 3 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/templated_test_cases.cpp.txt b/examples/all_features/test_output/templated_test_cases.cpp.txt
index e8c2b4f8..b3d33366 100644
--- a/examples/all_features/test_output/templated_test_cases.cpp.txt
+++ b/examples/all_features/test_output/templated_test_cases.cpp.txt
@@ -47,4 +47,5 @@ with expansion:
===============================================================================
[doctest] test cases: 14 | 9 passed | 5 failed |
[doctest] assertions: 18 | 13 passed | 5 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/test_cases_and_suites.cpp.txt b/examples/all_features/test_output/test_cases_and_suites.cpp.txt
index 9bd9c305..dd35fff9 100644
--- a/examples/all_features/test_output/test_cases_and_suites.cpp.txt
+++ b/examples/all_features/test_output/test_cases_and_suites.cpp.txt
@@ -39,5 +39,6 @@ with expansion:
===============================================================================
[doctest] test cases: 6 | 1 passed | 5 failed |
-[doctest] assertions: 2 | 1 passed | 1 failed |
+[doctest] assertions: 5 | 1 passed | 4 failed |
+[doctest] Status: FAILURE!
Program code.
diff --git a/examples/exe_with_static_libs/test_output/exe_with_static_libs.txt b/examples/exe_with_static_libs/test_output/exe_with_static_libs.txt
index 7fad5453..ee8875b3 100644
--- a/examples/exe_with_static_libs/test_output/exe_with_static_libs.txt
+++ b/examples/exe_with_static_libs/test_output/exe_with_static_libs.txt
@@ -6,3 +6,4 @@ hello from <main.cpp>
===============================================================================
[doctest] test cases: 4 | 4 passed | 0 failed | 0 skipped
[doctest] assertions: 0 | 0 passed | 0 failed |
+[doctest] Status: SUCCESS!
diff --git a/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt b/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt
index 1a610cca..642706b1 100644
--- a/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt
+++ b/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt
@@ -15,3 +15,4 @@ I am a test from the plugin!
===============================================================================
[doctest] test cases: 5 | 4 passed | 1 failed | 0 skipped
[doctest] assertions: 0 | 0 passed | 0 failed |
+[doctest] Status: FAILURE!
diff --git a/scripts/playground/test.cpp b/scripts/playground/test.cpp
index 73a5ed38..d8e65fc0 100644
--- a/scripts/playground/test.cpp
+++ b/scripts/playground/test.cpp
@@ -1,23 +1,64 @@
+//#define DOCTEST_CONFIG_DISABLE
#include "parts/doctest_fwd.h"
#include <iostream>
using namespace std;
-//static int throws(bool in) { if(in) throw 42; return 0; }
-TEST_SUITE("omg")
-//namespace
-{
- TEST_CASE("dev stuff") {
- SUBCASE("sc1") {
- CHECK(4 == 5);
- }
- SUBCASE("sc2") {
- CHECK(4 == 5);
- }
- //CHECK_THROWS(CHECK_THROWS(4 == 5));
- //CHECK_THROWS({throws(true);});
- }
- TEST_CASE("asd 2") {
- CHECK(4 == 5);
- }
+TEST_CASE("asd 4"
+ * doctest::test_suite("override")
+ * doctest::description("override")
+ * doctest::skip(false)
+ //* doctest::should_fail()
+ * doctest::expected_failures(2)
+) {
+ FAIL_CHECK("");
+ //FAIL_CHECK("");
}
+
+//TEST_CASE("") {
+// CHECK(true);
+//}
+
+//TEST_SUITE_BEGIN("stack"
+// * doctest::skip_if(true)
+// * doctest::description("stack")
+//);
+//
+//TEST_SUITE("scope"
+// * doctest::skip_if(false)
+// * doctest::description("scope")
+//) {
+// TEST_CASE("asd 1"
+// * doctest::test_suite("override")
+// * doctest::description("override")
+// * doctest::skip_if(false)
+// ) {
+// FAIL("");
+// }
+// TEST_CASE("asd 2"
+// //* doctest::test_suite("override")
+// //* doctest::description("override")
+// //* doctest::skip_if(false)
+// ) {
+// FAIL("");
+// }
+//
+//} // scope ts end
+//
+//TEST_CASE("asd 3"
+// //* doctest::test_suite("override")
+// //* doctest::description("override")
+// //* doctest::skip_if(false)
+// ) {
+// FAIL("");
+//}
+//
+//TEST_SUITE_END;
+//
+//TEST_CASE("asd 4"
+// //* doctest::test_suite("override")
+// //* doctest::description("override")
+// //* doctest::skip_if(false)
+// ) {
+// FAIL("");
+//}
diff --git a/scripts/playground/test_output/playground.txt b/scripts/playground/test_output/playground.txt
index ec935904..f02f7fd9 100644
--- a/scripts/playground/test_output/playground.txt
+++ b/scripts/playground/test_output/playground.txt
@@ -1,36 +1,14 @@
[doctest] run with "--help" for options
===============================================================================
test.cpp(0)
-TEST SUITE: omg
-TEST CASE: dev stuff
- sc1
+DESCRIPTION: override
+TEST SUITE: override
+TEST CASE: asd 4
test.cpp(0) ERROR!
- CHECK( 4 == 5 )
-with expansion:
- CHECK( 4 == 5 )
+Didn't fail exactly 2 times so marking it as failed!
===============================================================================
-test.cpp(0)
-TEST SUITE: omg
-TEST CASE: dev stuff
- sc2
-
-test.cpp(0) ERROR!
- CHECK( 4 == 5 )
-with expansion:
- CHECK( 4 == 5 )
-
-===============================================================================
-test.cpp(0)
-TEST SUITE: omg
-TEST CASE: asd 2
-
-test.cpp(0) ERROR!
- CHECK( 4 == 5 )
-with expansion:
- CHECK( 4 == 5 )
-
-===============================================================================
-[doctest] test cases: 2 | 0 passed | 2 failed | 0 skipped
-[doctest] assertions: 3 | 0 passed | 3 failed |
+[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped
+[doctest] assertions: 1 | 0 passed | 1 failed |
+[doctest] Status: FAILURE!