diff options
author | onqtam <vik.kirilov@gmail.com> | 2017-05-01 20:25:09 +0300 |
---|---|---|
committer | onqtam <vik.kirilov@gmail.com> | 2017-05-16 00:22:22 +0300 |
commit | 7630535ce91405bab07030b4912c0d584c731151 (patch) | |
tree | d45298e5a1b2f69bd240f24d7e53318e487a0410 | |
parent | 321f27033414d0a3d45c6c51296121ef416d5dea (diff) |
more code coverage
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | doctest/doctest.h | 17 | ||||
-rw-r--r-- | doctest/parts/doctest_impl.h | 17 | ||||
-rw-r--r-- | examples/all_features/CMakeLists.txt | 42 | ||||
-rw-r--r-- | examples/all_features/coverage_maxout.cpp | 19 | ||||
-rw-r--r-- | examples/all_features/logging.cpp | 5 | ||||
-rw-r--r-- | examples/all_features/test_output/all_binary_success.txt | 249 | ||||
-rw-r--r-- | examples/all_features/test_output/count.txt | 3 | ||||
-rw-r--r-- | examples/all_features/test_output/coverage_maxout.cpp.txt | 18 | ||||
-rw-r--r-- | examples/all_features/test_output/help.txt | 54 | ||||
-rw-r--r-- | examples/all_features/test_output/list_test_cases.txt | 7 | ||||
-rw-r--r-- | examples/all_features/test_output/list_test_suites.txt | 5 | ||||
-rw-r--r-- | examples/all_features/test_output/logging.cpp.txt | 12 | ||||
-rw-r--r-- | examples/all_features/test_output/order_1.txt | 43 | ||||
-rw-r--r-- | examples/all_features/test_output/order_2.txt | 43 | ||||
-rw-r--r-- | examples/all_features/test_output/order_3.txt | 5 | ||||
-rw-r--r-- | examples/all_features/test_output/version.txt | 0 |
17 files changed, 503 insertions, 38 deletions
diff --git a/.travis.yml b/.travis.yml index c85ae15b..e9b62b1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -349,7 +349,7 @@ script: # coverage - do not continue with other build configurations after that - | if [[ "${CODE_COVERAGE}" = "true" ]]; then - cmake ${CMAKE_OPTIONS_GLOBAL} ${CMAKE_OPTIONS} -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage" -DCMAKE_BUILD_TYPE=Debug . + cmake ${CMAKE_OPTIONS_GLOBAL} ${CMAKE_OPTIONS} -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage -std=c++98" -DCMAKE_BUILD_TYPE=Debug . make -k -j2 ctest --output-on-failure diff --git a/doctest/doctest.h b/doctest/doctest.h index 2cc3f8c7..b3455cdc 100644 --- a/doctest/doctest.h +++ b/doctest/doctest.h @@ -3920,7 +3920,16 @@ namespace detail } void printSummary(); - void reportFatal(std::string const& message) { + +#if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH) + void reportFatal(const std::string&) {} + struct FatalConditionHandler + { + void reset() {} + }; +#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH + + void reportFatal(const std::string& message) { DOCTEST_LOG_START(); detail::ContextState* p = getContextState(); @@ -3932,12 +3941,6 @@ namespace detail printSummary(); } -#if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH) - struct FatalConditionHandler - { - void reset() {} - }; -#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH #ifdef DOCTEST_PLATFORM_WINDOWS struct SignalDefs diff --git a/doctest/parts/doctest_impl.h b/doctest/parts/doctest_impl.h index 1dc28395..beba7124 100644 --- a/doctest/parts/doctest_impl.h +++ b/doctest/parts/doctest_impl.h @@ -1040,7 +1040,16 @@ namespace detail } void printSummary(); - void reportFatal(std::string const& message) { + +#if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH) + void reportFatal(const std::string&) {} + struct FatalConditionHandler + { + void reset() {} + }; +#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH + + void reportFatal(const std::string& message) { DOCTEST_LOG_START(); detail::ContextState* p = getContextState(); @@ -1052,12 +1061,6 @@ namespace detail printSummary(); } -#if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH) - struct FatalConditionHandler - { - void reset() {} - }; -#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH #ifdef DOCTEST_PLATFORM_WINDOWS struct SignalDefs diff --git a/examples/all_features/CMakeLists.txt b/examples/all_features/CMakeLists.txt index 2905f274..a0f9194f 100644 --- a/examples/all_features/CMakeLists.txt +++ b/examples/all_features/CMakeLists.txt @@ -22,33 +22,37 @@ set(files doctest_add_executable(${PROJECT_NAME} ${files}) target_compile_definitions(${PROJECT_NAME} PRIVATE DOCTEST_CONFIG_COLORS_NONE DOCTEST_CONFIG_NO_POSIX_SIGNALS) # easy way to fix test coverage +set(common_test_args COMMAND $<TARGET_FILE:${PROJECT_NAME}> --no-skipped-summary=1) + # add per-file tests foreach(f ${files}) - doctest_add_test(NAME ${f} COMMAND $<TARGET_FILE:${PROJECT_NAME}> --dt-no-skipped-summary=1 --source-file=*${f}) + doctest_add_test(NAME ${f} ${common_test_args} -sf=*${f}) endforeach() +set(common_cov_args ${common_test_args} -sf=*coverage*) + # queries -doctest_add_test(NAME help COMMAND $<TARGET_FILE:${PROJECT_NAME}> -dt-h) -doctest_add_test(NAME version COMMAND $<TARGET_FILE:${PROJECT_NAME}> -v) -doctest_add_test(NAME count COMMAND $<TARGET_FILE:${PROJECT_NAME}> -c) -doctest_add_test(NAME list_test_cases COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ltc) -doctest_add_test(NAME list_test_suites COMMAND $<TARGET_FILE:${PROJECT_NAME}> -lts) +doctest_add_test(NAME help ${common_cov_args} -h) +doctest_add_test(NAME version ${common_cov_args} -v) +doctest_add_test(NAME count ${common_cov_args} -c) +doctest_add_test(NAME list_test_cases ${common_cov_args} -ltc) +doctest_add_test(NAME list_test_suites ${common_cov_args} -lts) -doctest_add_test(NAME all_binary_success COMMAND $<TARGET_FILE:${PROJECT_NAME}> --test-case="all binary assertions" --success) +doctest_add_test(NAME all_binary_success ${common_test_args} -tc=all?binary* -s) ## options -#doctest_add_test(NAME successful COMMAND $<TARGET_FILE:${PROJECT_NAME}> -s=true -e=Off -sfe=*main*) # exclude main because of RawMemoryToStr -#doctest_add_test(NAME abort_after COMMAND $<TARGET_FILE:${PROJECT_NAME}> -aa=3 -no-colors) -#doctest_add_test(NAME first_last COMMAND $<TARGET_FILE:${PROJECT_NAME}> -f=2 -l=5) -#doctest_add_test(NAME filter_1 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tc=assert*********) -#doctest_add_test(NAME filter_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tce=???ert*) -#doctest_add_test(NAME filter_3 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sf=asgghdgsa) -#doctest_add_test(NAME filter_4 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sfe=*test.cpp*) -#doctest_add_test(NAME filter_5 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ts=ts1) -#doctest_add_test(NAME filter_6 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tse=ts1) -#doctest_add_test(NAME order_1 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=suite) -#doctest_add_test(NAME order_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=name) -#doctest_add_test(NAME order_3 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=rand -rs=324 -sfe=*) # sfe=* to exclude all tests for no output +#doctest_add_test(NAME successful ${common_cov_args} -s=true -e=Off -sfe=*main*) +#doctest_add_test(NAME abort_after ${common_cov_args} -aa=3 -no-colors) +#doctest_add_test(NAME first_last ${common_cov_args} -f=2 -l=5) +#doctest_add_test(NAME filter_1 ${common_cov_args} -tc=assert*********) +#doctest_add_test(NAME filter_2 ${common_cov_args} -tce=???ert*) +#doctest_add_test(NAME filter_3 ${common_cov_args} -sf=asgghdgsa) +#doctest_add_test(NAME filter_4 ${common_cov_args} -sfe=*test.cpp*) +#doctest_add_test(NAME filter_5 ${common_cov_args} -ts=ts1) +#doctest_add_test(NAME filter_6 ${common_cov_args} -tse=ts1) +doctest_add_test(NAME order_1 ${common_test_args} -sf=*test_cases_and_suites.cpp -ob=suite) +doctest_add_test(NAME order_2 ${common_test_args} -sf=*test_cases_and_suites.cpp -ob=name) +doctest_add_test(NAME order_3 ${common_test_args} -sf=*test_cases_and_suites.cpp -ob=rand -rs=324 -sfe=*) # sfe=* to exclude all tests for no output ################################################################################ ## VARIATION OF THE BUILD WITH DOCTEST DISABLED - SHOULD STILL COMPILE diff --git a/examples/all_features/coverage_maxout.cpp b/examples/all_features/coverage_maxout.cpp index bb864ee0..68e24849 100644 --- a/examples/all_features/coverage_maxout.cpp +++ b/examples/all_features/coverage_maxout.cpp @@ -28,8 +28,13 @@ TEST_CASE("doctest internals") { CHECK(a.compare("omgomgomg", false) == 0); // toString - a += toString("aaa") + toString(0.5f) + toString('c') + toString(true) + - toString(static_cast<long double>(0.1)) // + a += toString("aaa") // + + toString(true) // + + toString(0.5f) // + + toString(0.5) // + + toString(static_cast<long double>(0.1)) // + + toString('c') // + + toString(static_cast<signed char>('c')) // + toString(static_cast<unsigned char>(1)) // + toString(static_cast<short>(1)) // + toString(static_cast<long>(1)) // @@ -40,7 +45,9 @@ TEST_CASE("doctest internals") { //a += doctest::detail::fileForOutput("c:\\a"); //a += doctest::detail::fileForOutput("c:/a"); //a += doctest::detail::fileForOutput("a"); + std::ostringstream oss; + // trigger code path for String to ostream through operator<< oss << a; // trigger code path for assert string of a non-existent assert type oss << doctest::detail::getAssertString(static_cast<doctest::detail::assertType::Enum>(3)); @@ -49,4 +56,12 @@ TEST_CASE("doctest internals") { CHECK(doctest::detail::rawMemoryToString(a).length() > 0u); } +TEST_CASE("will end from a std::string exception") { + throw_if(true, std::string("std::string!")); +} + +TEST_CASE("will end from a const char* exception") { + throw_if(true, "const char*!"); +} + #endif // DOCTEST_CONFIG_DISABLE diff --git a/examples/all_features/logging.cpp b/examples/all_features/logging.cpp index 5d35d671..2dd05717 100644 --- a/examples/all_features/logging.cpp +++ b/examples/all_features/logging.cpp @@ -43,6 +43,11 @@ TEST_CASE("a test case that will end from an exception") { } } +TEST_CASE("a test case that will end from an exception and should print the unprinted context") { + INFO("should be printed even if an exception is thrown and no assert fails before that"); + throw_if(true, 0); +} + static void thirdPartyAssert(bool result, bool is_fatal, const char* file, int line) { if(result == false) { if(is_fatal) diff --git a/examples/all_features/test_output/all_binary_success.txt b/examples/all_features/test_output/all_binary_success.txt new file mode 100644 index 00000000..19eb8b2c --- /dev/null +++ b/examples/all_features/test_output/all_binary_success.txt @@ -0,0 +1,249 @@ +[doctest] run with "--help" for options +=============================================================================== +assertion_macros.cpp(0) +TEST CASE: all binary assertions + +assertion_macros.cpp(0) PASSED! + WARN_EQ( 1, 1 ) +with expansion: + WARN_EQ( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + CHECK_EQ( 1, 1 ) +with expansion: + CHECK_EQ( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + REQUIRE_EQ( 1, 1 ) +with expansion: + REQUIRE_EQ( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + WARN_NE( 1, 0 ) +with expansion: + WARN_NE( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + CHECK_NE( 1, 0 ) +with expansion: + CHECK_NE( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + REQUIRE_NE( 1, 0 ) +with expansion: + REQUIRE_NE( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + WARN_GT( 1, 0 ) +with expansion: + WARN_GT( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + CHECK_GT( 1, 0 ) +with expansion: + CHECK_GT( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + REQUIRE_GT( 1, 0 ) +with expansion: + REQUIRE_GT( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + WARN_LT( 0, 1 ) +with expansion: + WARN_LT( 0, 1 ) + +assertion_macros.cpp(0) PASSED! + CHECK_LT( 0, 1 ) +with expansion: + CHECK_LT( 0, 1 ) + +assertion_macros.cpp(0) PASSED! + REQUIRE_LT( 0, 1 ) +with expansion: + REQUIRE_LT( 0, 1 ) + +assertion_macros.cpp(0) PASSED! + WARN_GE( 1, 1 ) +with expansion: + WARN_GE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + CHECK_GE( 1, 1 ) +with expansion: + CHECK_GE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + REQUIRE_GE( 1, 1 ) +with expansion: + REQUIRE_GE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + WARN_LE( 1, 1 ) +with expansion: + WARN_LE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + CHECK_LE( 1, 1 ) +with expansion: + CHECK_LE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + REQUIRE_LE( 1, 1 ) +with expansion: + REQUIRE_LE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + WARN_UNARY( 1 ) +with expansion: + WARN_UNARY( 1 ) + +assertion_macros.cpp(0) PASSED! + CHECK_UNARY( 1 ) +with expansion: + CHECK_UNARY( 1 ) + +assertion_macros.cpp(0) PASSED! + REQUIRE_UNARY( 1 ) +with expansion: + REQUIRE_UNARY( 1 ) + +assertion_macros.cpp(0) PASSED! + WARN_UNARY_FALSE( 0 ) +with expansion: + WARN_UNARY_FALSE( 0 ) + +assertion_macros.cpp(0) PASSED! + CHECK_UNARY_FALSE( 0 ) +with expansion: + CHECK_UNARY_FALSE( 0 ) + +assertion_macros.cpp(0) PASSED! + REQUIRE_UNARY_FALSE( 0 ) +with expansion: + REQUIRE_UNARY_FALSE( 0 ) + +assertion_macros.cpp(0) PASSED! + FAST_WARN_EQ( 1, 1 ) +with expansion: + FAST_WARN_EQ( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_CHECK_EQ( 1, 1 ) +with expansion: + FAST_CHECK_EQ( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_REQUIRE_EQ( 1, 1 ) +with expansion: + FAST_REQUIRE_EQ( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_WARN_NE( 1, 0 ) +with expansion: + FAST_WARN_NE( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + FAST_CHECK_NE( 1, 0 ) +with expansion: + FAST_CHECK_NE( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + FAST_REQUIRE_NE( 1, 0 ) +with expansion: + FAST_REQUIRE_NE( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + FAST_WARN_GT( 1, 0 ) +with expansion: + FAST_WARN_GT( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + FAST_CHECK_GT( 1, 0 ) +with expansion: + FAST_CHECK_GT( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + FAST_REQUIRE_GT( 1, 0 ) +with expansion: + FAST_REQUIRE_GT( 1, 0 ) + +assertion_macros.cpp(0) PASSED! + FAST_WARN_LT( 0, 1 ) +with expansion: + FAST_WARN_LT( 0, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_CHECK_LT( 0, 1 ) +with expansion: + FAST_CHECK_LT( 0, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_REQUIRE_LT( 0, 1 ) +with expansion: + FAST_REQUIRE_LT( 0, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_WARN_GE( 1, 1 ) +with expansion: + FAST_WARN_GE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_CHECK_GE( 1, 1 ) +with expansion: + FAST_CHECK_GE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_REQUIRE_GE( 1, 1 ) +with expansion: + FAST_REQUIRE_GE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_WARN_LE( 1, 1 ) +with expansion: + FAST_WARN_LE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_CHECK_LE( 1, 1 ) +with expansion: + FAST_CHECK_LE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_REQUIRE_LE( 1, 1 ) +with expansion: + FAST_REQUIRE_LE( 1, 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_WARN_UNARY( 1 ) +with expansion: + FAST_WARN_UNARY( 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_CHECK_UNARY( 1 ) +with expansion: + FAST_CHECK_UNARY( 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_REQUIRE_UNARY( 1 ) +with expansion: + FAST_REQUIRE_UNARY( 1 ) + +assertion_macros.cpp(0) PASSED! + FAST_WARN_UNARY_FALSE( 0 ) +with expansion: + FAST_WARN_UNARY_FALSE( 0 ) + +assertion_macros.cpp(0) PASSED! + FAST_CHECK_UNARY_FALSE( 0 ) +with expansion: + FAST_CHECK_UNARY_FALSE( 0 ) + +assertion_macros.cpp(0) PASSED! + FAST_REQUIRE_UNARY_FALSE( 0 ) +with expansion: + FAST_REQUIRE_UNARY_FALSE( 0 ) + +=============================================================================== +[doctest] test cases: 1 | 1 passed | 0 failed | +[doctest] assertions: 32 | 32 passed | 0 failed | +Program code. diff --git a/examples/all_features/test_output/count.txt b/examples/all_features/test_output/count.txt new file mode 100644 index 00000000..544b1833 --- /dev/null +++ b/examples/all_features/test_output/count.txt @@ -0,0 +1,3 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] number of tests passing the current filters: 3 diff --git a/examples/all_features/test_output/coverage_maxout.cpp.txt b/examples/all_features/test_output/coverage_maxout.cpp.txt index e710e488..319efea7 100644 --- a/examples/all_features/test_output/coverage_maxout.cpp.txt +++ b/examples/all_features/test_output/coverage_maxout.cpp.txt @@ -1,5 +1,21 @@ [doctest] run with "--help" for options =============================================================================== -[doctest] test cases: 1 | 1 passed | 0 failed | +coverage_maxout.cpp(0) +TEST CASE: will end from a std::string exception + +TEST CASE FAILED! +threw exception: + std::string! + +=============================================================================== +coverage_maxout.cpp(0) +TEST CASE: will end from a const char* exception + +TEST CASE FAILED! +threw exception: + const char*! + +=============================================================================== +[doctest] test cases: 3 | 1 passed | 2 failed | [doctest] assertions: 5 | 5 passed | 0 failed | Program code. diff --git a/examples/all_features/test_output/help.txt b/examples/all_features/test_output/help.txt new file mode 100644 index 00000000..05600fa2 --- /dev/null +++ b/examples/all_features/test_output/help.txt @@ -0,0 +1,54 @@ +[doctest] +[doctest] boolean values: "1/on/yes/true" or "0/off/no/false" +[doctest] filter values: "str1,str2,str3" (comma separated strings) +[doctest] +[doctest] filters use wildcards for matching strings +[doctest] something passes a filter if any of the strings in a filter matches +[doctest] +[doctest] ALL FLAGS, OPTIONS AND FILTERS ALSO AVAILABLE WITH A "dt-" PREFIX!!! +[doctest] +[doctest] Query flags - the program quits after them. Available: + + -?, --help, -h prints this message + -v, --version prints the version + -c, --count prints the number of matching tests + -ltc, --list-test-cases lists all matching tests by name + -lts, --list-test-suites lists all matching test suites + +[doctest] The available <int>/<string> options/filters are: + + -tc, --test-case=<filters> filters tests by their name + -tce, --test-case-exclude=<filters> filters OUT tests by their name + -sf, --source-file=<filters> filters tests by their file + -sfe, --source-file-exclude=<filters> filters OUT tests by their file + -ts, --test-suite=<filters> filters tests by their test suite + -tse, --test-suite-exclude=<filters> filters OUT tests by their test suite + -sc, --subcase=<filters> filters subcases by their name + -sce, --subcase-exclude=<filters> filters OUT subcases by their name + -ob, --order-by=<string> how the tests should be ordered + <string> - by [file/suite/name/rand] + -rs, --rand-seed=<int> seed for random ordering + -f, --first=<int> the first test passing the filters to + execute - for range-based execution + -l, --last=<int> the last test passing the filters to + execute - for range-based execution + -aa, --abort-after=<int> stop after <int> failed assertions + -scfl,--subcase-filter-levels=<int> apply filters for the first <int> levels + +[doctest] Bool options - can be used like flags and true is assumed. Available: + + -s, --success=<bool> include successful assertions in output + -cs, --case-sensitive=<bool> filters being treated as case sensitive + -e, --exit=<bool> exits after the tests finish + -nt, --no-throw=<bool> skips exceptions-related assert checks + -ne, --no-exitcode=<bool> returns (or exits) always with success + -nr, --no-run=<bool> skips all runtime doctest operations + -nv, --no-version=<bool> omit the framework version in the output + -nc, --no-colors=<bool> disables colors in output + -fc, --force-colors=<bool> use colors even when not in a tty + -nb, --no-breaks=<bool> disables breakpoints in debuggers + -npf, --no-path-filenames=<bool> only filenames and no paths in output + -nln, --no-line-numbers=<bool> 0 instead of real line numbers in output + +[doctest] for more information visit the project documentation + diff --git a/examples/all_features/test_output/list_test_cases.txt b/examples/all_features/test_output/list_test_cases.txt new file mode 100644 index 00000000..2f9dc139 --- /dev/null +++ b/examples/all_features/test_output/list_test_cases.txt @@ -0,0 +1,7 @@ +[doctest] run with "--help" for options +[doctest] listing all test case names +doctest internals +will end from a std::string exception +will end from a const char* exception +=============================================================================== +[doctest] number of tests passing the current filters: 3 diff --git a/examples/all_features/test_output/list_test_suites.txt b/examples/all_features/test_output/list_test_suites.txt new file mode 100644 index 00000000..540b37b5 --- /dev/null +++ b/examples/all_features/test_output/list_test_suites.txt @@ -0,0 +1,5 @@ +[doctest] run with "--help" for options +[doctest] listing all test suites + +=============================================================================== +[doctest] number of tests passing the current filters: 3 diff --git a/examples/all_features/test_output/logging.cpp.txt b/examples/all_features/test_output/logging.cpp.txt index 72e342f6..2fe5fce9 100644 --- a/examples/all_features/test_output/logging.cpp.txt +++ b/examples/all_features/test_output/logging.cpp.txt @@ -68,6 +68,16 @@ threw exception: =============================================================================== logging.cpp(0) +TEST CASE: a test case that will end from an exception and should print the unprinted context + +TEST CASE FAILED! +threw exception: + 0 +with context: + should be printed even if an exception is thrown and no assert fails before that + +=============================================================================== +logging.cpp(0) TEST CASE: third party asserts can report failures to doctest logging.cpp(0) ERROR! @@ -94,6 +104,6 @@ logging.cpp(0) FATAL ERROR! fail the test case and also end it =============================================================================== -[doctest] test cases: 5 | 0 passed | 5 failed | +[doctest] test cases: 6 | 0 passed | 6 failed | [doctest] assertions: 6 | 0 passed | 6 failed | Program code. diff --git a/examples/all_features/test_output/order_1.txt b/examples/all_features/test_output/order_1.txt new file mode 100644 index 00000000..9f306699 --- /dev/null +++ b/examples/all_features/test_output/order_1.txt @@ -0,0 +1,43 @@ +[doctest] run with "--help" for options +=============================================================================== +test_cases_and_suites.cpp(0) +TEST CASE: should fail because of an exception + +TEST CASE FAILED! +threw exception: + 0 + +=============================================================================== +test_cases_and_suites.cpp(0) +TEST CASE: fixtured test - not part of a test suite + +test_cases_and_suites.cpp(0) ERROR! + CHECK( data == 85 ) +with expansion: + CHECK( 21 == 85 ) + +=============================================================================== +test_cases_and_suites.cpp(0) +TEST SUITE: scoped test suite +TEST CASE: part of scoped + +test_cases_and_suites.cpp(0) FATAL ERROR! + +=============================================================================== +test_cases_and_suites.cpp(0) +TEST SUITE: scoped test suite +TEST CASE: part of scoped 2 + +test_cases_and_suites.cpp(0) FATAL ERROR! + +=============================================================================== +test_cases_and_suites.cpp(0) +TEST SUITE: some TS +TEST CASE: part of some TS + +test_cases_and_suites.cpp(0) FATAL ERROR! + +=============================================================================== +[doctest] test cases: 6 | 1 passed | 5 failed | +[doctest] assertions: 2 | 1 passed | 1 failed | +Program code. diff --git a/examples/all_features/test_output/order_2.txt b/examples/all_features/test_output/order_2.txt new file mode 100644 index 00000000..8df1a21e --- /dev/null +++ b/examples/all_features/test_output/order_2.txt @@ -0,0 +1,43 @@ +[doctest] run with "--help" for options +=============================================================================== +test_cases_and_suites.cpp(0) +TEST CASE: fixtured test - not part of a test suite + +test_cases_and_suites.cpp(0) ERROR! + CHECK( data == 85 ) +with expansion: + CHECK( 21 == 85 ) + +=============================================================================== +test_cases_and_suites.cpp(0) +TEST SUITE: scoped test suite +TEST CASE: part of scoped + +test_cases_and_suites.cpp(0) FATAL ERROR! + +=============================================================================== +test_cases_and_suites.cpp(0) +TEST SUITE: scoped test suite +TEST CASE: part of scoped 2 + +test_cases_and_suites.cpp(0) FATAL ERROR! + +=============================================================================== +test_cases_and_suites.cpp(0) +TEST SUITE: some TS +TEST CASE: part of some TS + +test_cases_and_suites.cpp(0) FATAL ERROR! + +=============================================================================== +test_cases_and_suites.cpp(0) +TEST CASE: should fail because of an exception + +TEST CASE FAILED! +threw exception: + 0 + +=============================================================================== +[doctest] test cases: 6 | 1 passed | 5 failed | +[doctest] assertions: 2 | 1 passed | 1 failed | +Program code. diff --git a/examples/all_features/test_output/order_3.txt b/examples/all_features/test_output/order_3.txt new file mode 100644 index 00000000..eca69f05 --- /dev/null +++ b/examples/all_features/test_output/order_3.txt @@ -0,0 +1,5 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 0 | 0 passed | 0 failed | +[doctest] assertions: 0 | 0 passed | 0 failed | +Program code. diff --git a/examples/all_features/test_output/version.txt b/examples/all_features/test_output/version.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/examples/all_features/test_output/version.txt |