test cases example done
diff --git a/examples/all_features/CMakeLists.txt b/examples/all_features/CMakeLists.txt
index 7c12048..a86ef09 100644
--- a/examples/all_features/CMakeLists.txt
+++ b/examples/all_features/CMakeLists.txt
@@ -16,7 +16,7 @@
subcases.cpp
logging.cpp
templated_test_cases.cpp
- test_suites.cpp
+ test_cases_and_suites.cpp
)
doctest_add_executable(${PROJECT_NAME} ${files})
diff --git a/examples/all_features/assertion_macros.cpp b/examples/all_features/assertion_macros.cpp
index 0be79ad..fb12504 100644
--- a/examples/all_features/assertion_macros.cpp
+++ b/examples/all_features/assertion_macros.cpp
@@ -4,16 +4,6 @@
#include <stdexcept>
-TEST_CASE("an empty test that will succeed") {}
-
-TEST_CASE("an empty test that will fail because of an exception") {
- throw_if(true, 0);
-}
-
-TEST_CASE("an empty test that will fail because of a std::exception") {
- throw_if(true, std::runtime_error("whops!"));
-}
-
TEST_CASE("normal macros") {
int a = 5;
int b = 5;
diff --git a/examples/all_features/subcases.cpp b/examples/all_features/subcases.cpp
index c760d8b..7192e82 100644
--- a/examples/all_features/subcases.cpp
+++ b/examples/all_features/subcases.cpp
@@ -31,6 +31,19 @@
}
}
+static void call_func() {
+ SUBCASE("sc1") {
+ MESSAGE("hello! from sc1");
+ }
+ SUBCASE("sc2") {
+ MESSAGE("hello! from sc2");
+ }
+}
+
+TEST_CASE("subcases can be used in a separate function as well") {
+ call_func();
+}
+
SCENARIO("vectors can be sized and resized") {
GIVEN("A vector with some items") {
std::vector<int> v(5);
diff --git a/examples/all_features/test_cases_and_suites.cpp b/examples/all_features/test_cases_and_suites.cpp
new file mode 100644
index 0000000..be5c5a1
--- /dev/null
+++ b/examples/all_features/test_cases_and_suites.cpp
@@ -0,0 +1,32 @@
+#include "doctest.h"
+
+#include "header.h"
+
+TEST_CASE("an empty test that will succeed - not part of a test suite") {}
+
+TEST_CASE("an empty test that will fail because of an exception") {
+ throw_if(true, 0);
+}
+
+TEST_SUITE("scoped test suite") {
+ TEST_CASE("part of scoped") {
+ FAIL("");
+ }
+
+ TEST_CASE("part of scoped 2") {
+ FAIL("");
+ }
+}
+
+TEST_SUITE_BEGIN("some TS"); // begin "some TS"
+
+TEST_CASE("part of some TS") {
+ FAIL("");
+}
+
+TEST_SUITE_END(); // ends "some TS"
+
+TEST_CASE_FIXTURE(SomeFixture, "fixtured test - not part of a test suite") {
+ data /= 2;
+ CHECK(data == 85);
+}
diff --git a/examples/all_features/test_output/assertion_macros.cpp.txt b/examples/all_features/test_output/assertion_macros.cpp.txt
index 74d2469..890941c 100644
--- a/examples/all_features/test_output/assertion_macros.cpp.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp.txt
@@ -1,22 +1,6 @@
[doctest] run with "--help" for options
== TEST CASE ==================================================================
assertion_macros.cpp(0)
-an empty test that will fail because of an exception
-
-TEST CASE FAILED!
-threw exception:
- 0
-
-== TEST CASE ==================================================================
-assertion_macros.cpp(0)
-an empty test that will fail because of a std::exception
-
-TEST CASE FAILED!
-threw exception:
- whops!
-
-== TEST CASE ==================================================================
-assertion_macros.cpp(0)
normal macros
assertion_macros.cpp(0) ERROR!
@@ -78,6 +62,6 @@
whops!
===============================================================================
-[doctest] test cases: 6 | 1 passed | 5 failed |
+[doctest] test cases: 3 | 0 passed | 3 failed |
[doctest] assertions: 17 | 7 passed | 10 failed |
Program code.
diff --git a/examples/all_features/test_output/logging.cpp.txt b/examples/all_features/test_output/logging.cpp.txt
index 25842d0..c6c02b6 100644
--- a/examples/all_features/test_output/logging.cpp.txt
+++ b/examples/all_features/test_output/logging.cpp.txt
@@ -78,6 +78,9 @@
logging.cpp(0) ERROR!
this should not end the test case, but mark it as failing
+logging.cpp(0) MESSAGE!
+ reached!
+
== TEST CASE ==================================================================
logging.cpp(0)
explicit failures 2
diff --git a/examples/all_features/test_output/subcases.cpp.txt b/examples/all_features/test_output/subcases.cpp.txt
index adfffb1..b6997b1 100644
--- a/examples/all_features/test_output/subcases.cpp.txt
+++ b/examples/all_features/test_output/subcases.cpp.txt
@@ -18,6 +18,22 @@
== TEST CASE ==================================================================
subcases.cpp(0)
+subcases can be used in a separate function as well
+ sc1
+
+subcases.cpp(0) MESSAGE!
+ hello! from sc1
+
+== TEST CASE ==================================================================
+subcases.cpp(0)
+subcases can be used in a separate function as well
+ sc2
+
+subcases.cpp(0) MESSAGE!
+ hello! from sc2
+
+== TEST CASE ==================================================================
+subcases.cpp(0)
Scenario: vectors can be sized and resized
Given: A vector with some items
When: the size is increased
@@ -41,6 +57,6 @@
CHECK( 5 == 10 )
===============================================================================
-[doctest] test cases: 2 | 0 passed | 2 failed |
+[doctest] test cases: 3 | 1 passed | 2 failed |
[doctest] assertions: 16 | 14 passed | 2 failed |
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
new file mode 100644
index 0000000..07e1041
--- /dev/null
+++ b/examples/all_features/test_output/test_cases_and_suites.cpp.txt
@@ -0,0 +1,40 @@
+[doctest] run with "--help" for options
+== TEST CASE ==================================================================
+test_cases_and_suites.cpp(0)
+an empty test that will fail because of an exception
+
+TEST CASE FAILED!
+threw exception:
+ 0
+
+== TEST CASE ==================================================================
+test_cases_and_suites.cpp(0)
+part of scoped
+
+test_cases_and_suites.cpp(0) FATAL ERROR!
+
+== TEST CASE ==================================================================
+test_cases_and_suites.cpp(0)
+part of scoped 2
+
+test_cases_and_suites.cpp(0) FATAL ERROR!
+
+== TEST CASE ==================================================================
+test_cases_and_suites.cpp(0)
+part of some TS
+
+test_cases_and_suites.cpp(0) FATAL ERROR!
+
+== TEST CASE ==================================================================
+test_cases_and_suites.cpp(0)
+fixtured test - not part of a test suite
+
+test_cases_and_suites.cpp(0) ERROR!
+ CHECK( data == 85 )
+with expansion:
+ CHECK( 21 == 85 )
+
+===============================================================================
+[doctest] test cases: 6 | 1 passed | 5 failed |
+[doctest] assertions: 1 | 0 passed | 1 failed |
+Program code.
diff --git a/examples/all_features/test_output/test_suites.cpp.txt b/examples/all_features/test_output/test_suites.cpp.txt
deleted file mode 100644
index 72a0678..0000000
--- a/examples/all_features/test_output/test_suites.cpp.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-[doctest] run with "--help" for options
-== TEST CASE ==================================================================
-test_suites.cpp(0)
-not part of a test suite
-
-test_suites.cpp(0) FATAL ERROR!
-
-== TEST CASE ==================================================================
-test_suites.cpp(0)
-part of scoped
-
-test_suites.cpp(0) FATAL ERROR!
-
-== TEST CASE ==================================================================
-test_suites.cpp(0)
-part of scoped 2
-
-test_suites.cpp(0) FATAL ERROR!
-
-== TEST CASE ==================================================================
-test_suites.cpp(0)
-part of some TS
-
-test_suites.cpp(0) FATAL ERROR!
-
-== TEST CASE ==================================================================
-test_suites.cpp(0)
-not part of a test suite 2
-
-test_suites.cpp(0) FATAL ERROR!
-
-===============================================================================
-[doctest] test cases: 5 | 0 passed | 5 failed |
-[doctest] assertions: 0 | 0 passed | 0 failed |
-Program code.
diff --git a/examples/all_features/test_suites.cpp b/examples/all_features/test_suites.cpp
deleted file mode 100644
index f08319c..0000000
--- a/examples/all_features/test_suites.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "doctest.h"
-
-TEST_CASE("not part of a test suite") {
- FAIL("");
-}
-
-TEST_SUITE("scoped test suite") {
- TEST_CASE("part of scoped") {
- FAIL("");
- }
-
- TEST_CASE("part of scoped 2") {
- FAIL("");
- }
-}
-
-TEST_SUITE_BEGIN("some TS"); // begin "some TS"
-
-TEST_CASE("part of some TS") {
- FAIL("");
-}
-
-TEST_SUITE_END(); // ends "some TS"
-
-TEST_CASE("not part of a test suite 2") {
- FAIL("");
-}
diff --git a/scripts/random_dev_notes.md b/scripts/random_dev_notes.md
index ada3457..d4fcff4 100644
--- a/scripts/random_dev_notes.md
+++ b/scripts/random_dev_notes.md
@@ -1,8 +1,6 @@
-asserts, logging macros
all macros!!!
-asserts in separate functions?
look at boost test again: