more coverage
diff --git a/examples/code_coverage/CMakeLists.txt b/examples/code_coverage/CMakeLists.txt
index b588397..7e7cfa4 100644
--- a/examples/code_coverage/CMakeLists.txt
+++ b/examples/code_coverage/CMakeLists.txt
@@ -21,13 +21,14 @@
add_test(NAME abort_after COMMAND $<TARGET_FILE:${PROJECT_NAME}> -aa=3)
add_test(NAME first_last COMMAND $<TARGET_FILE:${PROJECT_NAME}> -f=2 -l=5)
add_test(NAME filter_1 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tc=assert*)
-add_test(NAME filter_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tca=assert*)
-add_test(NAME filter_3 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sf=test*)
-add_test(NAME filter_4 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sfe=test*)
+add_test(NAME filter_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tce=???ert*)
+add_test(NAME filter_3 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sf=*test*)
+add_test(NAME filter_4 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sfe=*test*)
add_test(NAME filter_5 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ts=ts1)
add_test(NAME filter_6 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tse=ts1)
-
-
+add_test(NAME order_1 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=suite)
+add_test(NAME order_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=name)
+add_test(NAME order_3 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=rand -rs=324)
diff --git a/examples/code_coverage/main.cpp b/examples/code_coverage/main.cpp
index fa1bc85..55dbd96 100644
--- a/examples/code_coverage/main.cpp
+++ b/examples/code_coverage/main.cpp
@@ -2,13 +2,16 @@
#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"
+// intentionally here so there are subcases on the same lines in different files
TEST_CASE("subcases") {
SUBCASE("1") {
SUBCASE("1.1") {}
SUBCASE("1.2") {}
+ SUBCASE("1.2") {}
}
- SUBCASE("2") {}
- SUBCASE("3") {}
+ // clang-format off
+ SUBCASE("2") {} SUBCASE("3") {} // to have subcases on the same line with different names
+ // clang-format on
}
#include <iostream>
@@ -17,9 +20,8 @@
using doctest::toString;
-TEST_CASE("throws") {
- CHECK(1 == 2);
-
+TEST_CASE("doctest internals") {
+ // string stuff
doctest::String a;
a += "omg";
const doctest::String const_str("omgomgomg");
@@ -29,6 +31,7 @@
CHECK(a.compare(const_str, true) == 0);
CHECK(a.compare("omgomgomg", true) == 0);
+ // toString
cout << a << toString("aaa") << toString(0.5f) << toString('c')
<< toString(static_cast<long double>(0.1)) //
<< toString(static_cast<unsigned char>(1)) //
@@ -36,6 +39,12 @@
<< toString(static_cast<long>(1)) //
<< toString(static_cast<unsigned long>(1)) //
<< toString(static_cast<unsigned short>(1));
+
+ // others
+ cout << doctest::detail::fileForOutput("c:\\a") << doctest::detail::fileForOutput("c:/a")
+ << doctest::detail::fileForOutput("a");
+
+ doctest::detail::Subcase subcase("", "", 0);
}
int main(int argc, char** argv) {
diff --git a/examples/code_coverage/test.cpp b/examples/code_coverage/test.cpp
index e9727e5..4330d05 100644
--- a/examples/code_coverage/test.cpp
+++ b/examples/code_coverage/test.cpp
@@ -2,6 +2,7 @@
TEST_SUITE("ts2");
+// intentionally here so there are subcases on the same lines in different files
TEST_CASE("subcases") {
SUBCASE("1") {
SUBCASE("1.1") {}
@@ -28,10 +29,10 @@
//int* a = &iVar;
//int* b = a - 1;
//CHECK(a == b);
- CHECK(1 == false);
+ CHECK(1 == 0);
CHECK_FALSE(1);
CHECK(Approx(0.1) == 0.2);
-
+
CHECK_THROWS(throws(true));
CHECK_THROWS(throws(false));
CHECK_NOTHROW(throws(false));
diff --git a/examples/code_coverage/test_output/abort_after.txt b/examples/code_coverage/test_output/abort_after.txt
index f3f6421..92dec19 100644
--- a/examples/code_coverage/test_output/abort_after.txt
+++ b/examples/code_coverage/test_output/abort_after.txt
@@ -1,33 +1,29 @@
[doctest] doctest version is "1.0.0"
[doctest] run with "--help" for options
-===============================================================================
-main.cpp(20)
-throws
-
-main.cpp(21) FAILED!
- CHECK( 1 == 2 )
-with expansion:
- CHECK( 1 == 2 )
-
-omgomgomg"aaa"0.5f990.11d1111===============================================================================
-test.cpp(5)
+omgomgomg"aaa"0.5f990.11d1111aaa===============================================================================
+test.cpp(6)
subcases
2
-test.cpp(10) FAILED!
+test.cpp(11) FAILED!
CHECK( 0 )
with expansion:
CHECK( 0 )
===============================================================================
-test.cpp(26)
+test.cpp(27)
assertions
-test.cpp(31) FAILED!
- CHECK( 1 == false )
+test.cpp(32) FAILED!
+ CHECK( 1 == 0 )
with expansion:
- CHECK( 1 == false )
+ CHECK( 1 == 0 )
+
+test.cpp(33) FAILED!
+ CHECK_FALSE( 1 )
+with expansion:
+ CHECK_FALSE( 1 )
===============================================================================
-[doctest] test cases: 4 | 1 passed | 3 failed | 1 skipped
+[doctest] test cases: 4 | 2 passed | 2 failed | 1 skipped
[doctest] assertions: 7 | 4 passed | 3 failed |
diff --git a/examples/code_coverage/test_output/filter_1.txt b/examples/code_coverage/test_output/filter_1.txt
index 440b96f..2acf540 100644
--- a/examples/code_coverage/test_output/filter_1.txt
+++ b/examples/code_coverage/test_output/filter_1.txt
@@ -1,31 +1,31 @@
[doctest] doctest version is "1.0.0"
[doctest] run with "--help" for options
===============================================================================
-test.cpp(26)
+test.cpp(27)
assertions
-test.cpp(31) FAILED!
- CHECK( 1 == false )
-with expansion:
- CHECK( 1 == false )
-
test.cpp(32) FAILED!
- CHECK_FALSE( 1 )
+ CHECK( 1 == 0 )
with expansion:
- CHECK_FALSE( 1 )
+ CHECK( 1 == 0 )
test.cpp(33) FAILED!
+ CHECK_FALSE( 1 )
+with expansion:
+ CHECK_FALSE( 1 )
+
+test.cpp(34) FAILED!
CHECK( Approx(0.1) == 0.2 )
with expansion:
CHECK( Approx( 0.1 ) == 0.2 )
-test.cpp(36) FAILED!
+test.cpp(37) FAILED!
CHECK_THROWS( throws(false) )
-test.cpp(38) FAILED!
+test.cpp(39) FAILED!
CHECK_NOTHROW( throws(true) )
-test.cpp(40) FAILED! (didn't throw at all)
+test.cpp(41) FAILED! (didn't throw at all)
CHECK_THROWS_AS( throws(false), bool )
===============================================================================
diff --git a/examples/code_coverage/test_output/filter_2.txt b/examples/code_coverage/test_output/filter_2.txt
index a7eed99..612a69d 100644
--- a/examples/code_coverage/test_output/filter_2.txt
+++ b/examples/code_coverage/test_output/filter_2.txt
@@ -1,58 +1,21 @@
[doctest] doctest version is "1.0.0"
[doctest] run with "--help" for options
-===============================================================================
-main.cpp(20)
-throws
-
-main.cpp(21) FAILED!
- CHECK( 1 == 2 )
-with expansion:
- CHECK( 1 == 2 )
-
-omgomgomg"aaa"0.5f990.11d1111===============================================================================
-test.cpp(5)
+omgomgomg"aaa"0.5f990.11d1111aaa===============================================================================
+test.cpp(6)
subcases
2
-test.cpp(10) FAILED!
+test.cpp(11) FAILED!
CHECK( 0 )
with expansion:
CHECK( 0 )
===============================================================================
-test.cpp(26)
-assertions
-
-test.cpp(31) FAILED!
- CHECK( 1 == false )
-with expansion:
- CHECK( 1 == false )
-
-test.cpp(32) FAILED!
- CHECK_FALSE( 1 )
-with expansion:
- CHECK_FALSE( 1 )
-
-test.cpp(33) FAILED!
- CHECK( Approx(0.1) == 0.2 )
-with expansion:
- CHECK( Approx( 0.1 ) == 0.2 )
-
-test.cpp(36) FAILED!
- CHECK_THROWS( throws(false) )
-
-test.cpp(38) FAILED!
- CHECK_NOTHROW( throws(true) )
-
-test.cpp(40) FAILED! (didn't throw at all)
- CHECK_THROWS_AS( throws(false), bool )
-
-===============================================================================
-test.cpp(43)
+test.cpp(44)
throws
TEST CASE FAILED! (threw exception)
===============================================================================
-[doctest] test cases: 5 | 1 passed | 4 failed | 0 skipped
-[doctest] assertions: 15 | 7 passed | 8 failed |
+[doctest] test cases: 4 | 2 passed | 2 failed | 1 skipped
+[doctest] assertions: 5 | 4 passed | 1 failed |
diff --git a/examples/code_coverage/test_output/filter_3.txt b/examples/code_coverage/test_output/filter_3.txt
index f3798f8..2669494 100644
--- a/examples/code_coverage/test_output/filter_3.txt
+++ b/examples/code_coverage/test_output/filter_3.txt
@@ -1,5 +1,49 @@
[doctest] doctest version is "1.0.0"
[doctest] run with "--help" for options
+omgomgomg"aaa"0.5f990.11d1111aaa===============================================================================
+test.cpp(6)
+subcases
+ 2
+
+test.cpp(11) FAILED!
+ CHECK( 0 )
+with expansion:
+ CHECK( 0 )
+
===============================================================================
-[doctest] test cases: 0 | 0 passed | 0 failed | 5 skipped
-[doctest] assertions: 0 | 0 passed | 0 failed |
+test.cpp(27)
+assertions
+
+test.cpp(32) FAILED!
+ CHECK( 1 == 0 )
+with expansion:
+ CHECK( 1 == 0 )
+
+test.cpp(33) FAILED!
+ CHECK_FALSE( 1 )
+with expansion:
+ CHECK_FALSE( 1 )
+
+test.cpp(34) FAILED!
+ CHECK( Approx(0.1) == 0.2 )
+with expansion:
+ CHECK( Approx( 0.1 ) == 0.2 )
+
+test.cpp(37) FAILED!
+ CHECK_THROWS( throws(false) )
+
+test.cpp(39) FAILED!
+ CHECK_NOTHROW( throws(true) )
+
+test.cpp(41) FAILED! (didn't throw at all)
+ CHECK_THROWS_AS( throws(false), bool )
+
+===============================================================================
+test.cpp(44)
+throws
+
+TEST CASE FAILED! (threw exception)
+
+===============================================================================
+[doctest] test cases: 5 | 2 passed | 3 failed | 0 skipped
+[doctest] assertions: 14 | 7 passed | 7 failed |
diff --git a/examples/code_coverage/test_output/filter_4.txt b/examples/code_coverage/test_output/filter_4.txt
index a7eed99..f3798f8 100644
--- a/examples/code_coverage/test_output/filter_4.txt
+++ b/examples/code_coverage/test_output/filter_4.txt
@@ -1,58 +1,5 @@
[doctest] doctest version is "1.0.0"
[doctest] run with "--help" for options
===============================================================================
-main.cpp(20)
-throws
-
-main.cpp(21) FAILED!
- CHECK( 1 == 2 )
-with expansion:
- CHECK( 1 == 2 )
-
-omgomgomg"aaa"0.5f990.11d1111===============================================================================
-test.cpp(5)
-subcases
- 2
-
-test.cpp(10) FAILED!
- CHECK( 0 )
-with expansion:
- CHECK( 0 )
-
-===============================================================================
-test.cpp(26)
-assertions
-
-test.cpp(31) FAILED!
- CHECK( 1 == false )
-with expansion:
- CHECK( 1 == false )
-
-test.cpp(32) FAILED!
- CHECK_FALSE( 1 )
-with expansion:
- CHECK_FALSE( 1 )
-
-test.cpp(33) FAILED!
- CHECK( Approx(0.1) == 0.2 )
-with expansion:
- CHECK( Approx( 0.1 ) == 0.2 )
-
-test.cpp(36) FAILED!
- CHECK_THROWS( throws(false) )
-
-test.cpp(38) FAILED!
- CHECK_NOTHROW( throws(true) )
-
-test.cpp(40) FAILED! (didn't throw at all)
- CHECK_THROWS_AS( throws(false), bool )
-
-===============================================================================
-test.cpp(43)
-throws
-
-TEST CASE FAILED! (threw exception)
-
-===============================================================================
-[doctest] test cases: 5 | 1 passed | 4 failed | 0 skipped
-[doctest] assertions: 15 | 7 passed | 8 failed |
+[doctest] test cases: 0 | 0 passed | 0 failed | 5 skipped
+[doctest] assertions: 0 | 0 passed | 0 failed |
diff --git a/examples/code_coverage/test_output/filter_5.txt b/examples/code_coverage/test_output/filter_5.txt
index 5457f97..ef30c78 100644
--- a/examples/code_coverage/test_output/filter_5.txt
+++ b/examples/code_coverage/test_output/filter_5.txt
@@ -1,35 +1,35 @@
[doctest] doctest version is "1.0.0"
[doctest] run with "--help" for options
===============================================================================
-test.cpp(26)
+test.cpp(27)
assertions
-test.cpp(31) FAILED!
- CHECK( 1 == false )
-with expansion:
- CHECK( 1 == false )
-
test.cpp(32) FAILED!
- CHECK_FALSE( 1 )
+ CHECK( 1 == 0 )
with expansion:
- CHECK_FALSE( 1 )
+ CHECK( 1 == 0 )
test.cpp(33) FAILED!
+ CHECK_FALSE( 1 )
+with expansion:
+ CHECK_FALSE( 1 )
+
+test.cpp(34) FAILED!
CHECK( Approx(0.1) == 0.2 )
with expansion:
CHECK( Approx( 0.1 ) == 0.2 )
-test.cpp(36) FAILED!
+test.cpp(37) FAILED!
CHECK_THROWS( throws(false) )
-test.cpp(38) FAILED!
+test.cpp(39) FAILED!
CHECK_NOTHROW( throws(true) )
-test.cpp(40) FAILED! (didn't throw at all)
+test.cpp(41) FAILED! (didn't throw at all)
CHECK_THROWS_AS( throws(false), bool )
===============================================================================
-test.cpp(43)
+test.cpp(44)
throws
TEST CASE FAILED! (threw exception)
diff --git a/examples/code_coverage/test_output/filter_6.txt b/examples/code_coverage/test_output/filter_6.txt
index 9a8fe55..2151619 100644
--- a/examples/code_coverage/test_output/filter_6.txt
+++ b/examples/code_coverage/test_output/filter_6.txt
@@ -1,24 +1,15 @@
[doctest] doctest version is "1.0.0"
[doctest] run with "--help" for options
-===============================================================================
-main.cpp(20)
-throws
-
-main.cpp(21) FAILED!
- CHECK( 1 == 2 )
-with expansion:
- CHECK( 1 == 2 )
-
-omgomgomg"aaa"0.5f990.11d1111===============================================================================
-test.cpp(5)
+omgomgomg"aaa"0.5f990.11d1111aaa===============================================================================
+test.cpp(6)
subcases
2
-test.cpp(10) FAILED!
+test.cpp(11) FAILED!
CHECK( 0 )
with expansion:
CHECK( 0 )
===============================================================================
-[doctest] test cases: 3 | 1 passed | 2 failed | 2 skipped
-[doctest] assertions: 6 | 4 passed | 2 failed |
+[doctest] test cases: 3 | 2 passed | 1 failed | 2 skipped
+[doctest] assertions: 5 | 4 passed | 1 failed |
diff --git a/examples/code_coverage/test_output/first_last.txt b/examples/code_coverage/test_output/first_last.txt
index a7eed99..2669494 100644
--- a/examples/code_coverage/test_output/first_last.txt
+++ b/examples/code_coverage/test_output/first_last.txt
@@ -1,58 +1,49 @@
[doctest] doctest version is "1.0.0"
[doctest] run with "--help" for options
-===============================================================================
-main.cpp(20)
-throws
-
-main.cpp(21) FAILED!
- CHECK( 1 == 2 )
-with expansion:
- CHECK( 1 == 2 )
-
-omgomgomg"aaa"0.5f990.11d1111===============================================================================
-test.cpp(5)
+omgomgomg"aaa"0.5f990.11d1111aaa===============================================================================
+test.cpp(6)
subcases
2
-test.cpp(10) FAILED!
+test.cpp(11) FAILED!
CHECK( 0 )
with expansion:
CHECK( 0 )
===============================================================================
-test.cpp(26)
+test.cpp(27)
assertions
-test.cpp(31) FAILED!
- CHECK( 1 == false )
-with expansion:
- CHECK( 1 == false )
-
test.cpp(32) FAILED!
- CHECK_FALSE( 1 )
+ CHECK( 1 == 0 )
with expansion:
- CHECK_FALSE( 1 )
+ CHECK( 1 == 0 )
test.cpp(33) FAILED!
+ CHECK_FALSE( 1 )
+with expansion:
+ CHECK_FALSE( 1 )
+
+test.cpp(34) FAILED!
CHECK( Approx(0.1) == 0.2 )
with expansion:
CHECK( Approx( 0.1 ) == 0.2 )
-test.cpp(36) FAILED!
+test.cpp(37) FAILED!
CHECK_THROWS( throws(false) )
-test.cpp(38) FAILED!
+test.cpp(39) FAILED!
CHECK_NOTHROW( throws(true) )
-test.cpp(40) FAILED! (didn't throw at all)
+test.cpp(41) FAILED! (didn't throw at all)
CHECK_THROWS_AS( throws(false), bool )
===============================================================================
-test.cpp(43)
+test.cpp(44)
throws
TEST CASE FAILED! (threw exception)
===============================================================================
-[doctest] test cases: 5 | 1 passed | 4 failed | 0 skipped
-[doctest] assertions: 15 | 7 passed | 8 failed |
+[doctest] test cases: 5 | 2 passed | 3 failed | 0 skipped
+[doctest] assertions: 14 | 7 passed | 7 failed |
diff --git a/examples/code_coverage/test_output/list_test_cases.txt b/examples/code_coverage/test_output/list_test_cases.txt
index e714d55..669f109 100644
--- a/examples/code_coverage/test_output/list_test_cases.txt
+++ b/examples/code_coverage/test_output/list_test_cases.txt
@@ -2,7 +2,7 @@
[doctest] run with "--help" for options
[doctest] listing all test case names
subcases
-throws
+doctest internals
subcases
assertions
throws
diff --git a/examples/code_coverage/test_output/successful.txt b/examples/code_coverage/test_output/successful.txt
index a92b8c9..6826f9a 100644
--- a/examples/code_coverage/test_output/successful.txt
+++ b/examples/code_coverage/test_output/successful.txt
@@ -1,95 +1,90 @@
[doctest] doctest version is "1.0.0"
[doctest] run with "--help" for options
===============================================================================
-main.cpp(5)
+main.cpp(6)
subcases
===============================================================================
-main.cpp(20)
-throws
+main.cpp(23)
+doctest internals
-main.cpp(21) FAILED!
- CHECK( 1 == 2 )
-with expansion:
- CHECK( 1 == 2 )
-
-main.cpp(27) PASSED!
+main.cpp(29) PASSED!
CHECK( a.size() == const_str.size() )
with expansion:
CHECK( 9 == 9 )
-main.cpp(28) PASSED!
+main.cpp(30) PASSED!
CHECK( a.length() == const_str.length() )
with expansion:
CHECK( 9 == 9 )
-main.cpp(29) PASSED!
+main.cpp(31) PASSED!
CHECK( a.compare(const_str, true) == 0 )
with expansion:
CHECK( 0 == 0 )
-main.cpp(30) PASSED!
+main.cpp(32) PASSED!
CHECK( a.compare("omgomgomg", true) == 0 )
with expansion:
CHECK( 0 == 0 )
-omgomgomg"aaa"0.5f990.11d1111===============================================================================
-test.cpp(5)
+omgomgomg"aaa"0.5f990.11d1111aaa===============================================================================
+test.cpp(6)
subcases
===============================================================================
-test.cpp(5)
+test.cpp(6)
subcases
2
-test.cpp(10) FAILED!
+test.cpp(11) FAILED!
CHECK( 0 )
with expansion:
CHECK( 0 )
===============================================================================
-test.cpp(26)
+test.cpp(27)
assertions
-test.cpp(31) FAILED!
- CHECK( 1 == false )
-with expansion:
- CHECK( 1 == false )
-
test.cpp(32) FAILED!
- CHECK_FALSE( 1 )
+ CHECK( 1 == 0 )
with expansion:
- CHECK_FALSE( 1 )
+ CHECK( 1 == 0 )
test.cpp(33) FAILED!
+ CHECK_FALSE( 1 )
+with expansion:
+ CHECK_FALSE( 1 )
+
+test.cpp(34) FAILED!
CHECK( Approx(0.1) == 0.2 )
with expansion:
CHECK( Approx( 0.1 ) == 0.2 )
-test.cpp(35) PASSED!
+test.cpp(36) PASSED!
CHECK_THROWS( throws(true) )
-test.cpp(36) FAILED!
+test.cpp(37) FAILED!
CHECK_THROWS( throws(false) )
-test.cpp(37) PASSED!
+test.cpp(38) PASSED!
CHECK_NOTHROW( throws(false) )
-test.cpp(38) FAILED!
+test.cpp(39) FAILED!
CHECK_NOTHROW( throws(true) )
-test.cpp(39) PASSED!
+test.cpp(40) PASSED!
CHECK_THROWS_AS( throws(true), bool )
-test.cpp(40) FAILED! (didn't throw at all)
+test.cpp(41) FAILED! (didn't throw at all)
CHECK_THROWS_AS( throws(false), bool )
===============================================================================
-test.cpp(43)
+test.cpp(44)
throws
TEST CASE FAILED! (threw exception)
===============================================================================
-[doctest] test cases: 5 | 1 passed | 4 failed | 0 skipped
-[doctest] assertions: 15 | 7 passed | 8 failed |
+[doctest] test cases: 5 | 2 passed | 3 failed | 0 skipped
+[doctest] assertions: 14 | 7 passed | 7 failed |