summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoronqtam <vik.kirilov@gmail.com>2016-05-31 18:24:00 +0300
committeronqtam <vik.kirilov@gmail.com>2016-09-21 15:46:07 +0300
commitbc4b56c5d642ae070af58536911c68d770b9cd72 (patch)
tree53da6bc1ed52a6bdc66fef661291a639779760bc /examples
parentf720d43865138bdf4131e2dc1b36f01adcc5abbb (diff)
fixed #10
also added an example using the parts of the doctest header (and fixed it to work)
Diffstat (limited to 'examples')
-rw-r--r--examples/alternative_macros/test_output/alternative_macros.txt6
-rw-r--r--examples/assertion_macros/test_output/assertion_macros.txt6
-rw-r--r--examples/hello_world/test_output/hello_world.txt6
-rw-r--r--examples/multi_file_example/test_output/multi_file_example.txt15
-rw-r--r--examples/separate_headers/CMakeLists.txt12
-rw-r--r--examples/separate_headers/main.cpp21
-rw-r--r--examples/separate_headers/test.cpp5
-rw-r--r--examples/separate_headers/test_output/separate_headers.txt5
-rw-r--r--examples/stringification/test_output/stringification.txt6
-rw-r--r--examples/subcases_and_bdd/test_output/subcases_and_bdd.txt6
-rw-r--r--examples/user_supplied_main/test_output/user_supplied_main.txt6
11 files changed, 73 insertions, 21 deletions
diff --git a/examples/alternative_macros/test_output/alternative_macros.txt b/examples/alternative_macros/test_output/alternative_macros.txt
index 6237a67..0661180 100644
--- a/examples/alternative_macros/test_output/alternative_macros.txt
+++ b/examples/alternative_macros/test_output/alternative_macros.txt
@@ -1,7 +1,7 @@
[doctest] doctest version is "1.0.0"
-[doctest] run with "-dt-help" for options
+[doctest] run with "--help" for options
Hello world!
Hello world!
===============================================================================
-[doctest] test cases: 1 | 1 passed | 0 failed
-[doctest] assertions: 4 | 4 passed | 0 failed
+[doctest] test cases: 1 | 1 passed | 0 failed | 0 skipped
+[doctest] assertions: 4 | 4 passed | 0 failed |
diff --git a/examples/assertion_macros/test_output/assertion_macros.txt b/examples/assertion_macros/test_output/assertion_macros.txt
index a0d5cda..2fa7c12 100644
--- a/examples/assertion_macros/test_output/assertion_macros.txt
+++ b/examples/assertion_macros/test_output/assertion_macros.txt
@@ -1,5 +1,5 @@
[doctest] doctest version is "1.0.0"
-[doctest] run with "-dt-help" for options
+[doctest] run with "--help" for options
===============================================================================
main.cpp(16)
an empty test that will fail because of an exception
@@ -37,5 +37,5 @@ main.cpp(47) FAILED!
REQUIRE_NOTHROW( throws(true) )
===============================================================================
-[doctest] test cases: 4 | 1 passed | 3 failed
-[doctest] assertions: 11 | 5 passed | 6 failed
+[doctest] test cases: 4 | 1 passed | 3 failed | 0 skipped
+[doctest] assertions: 11 | 5 passed | 6 failed |
diff --git a/examples/hello_world/test_output/hello_world.txt b/examples/hello_world/test_output/hello_world.txt
index ca7a9ad..0592078 100644
--- a/examples/hello_world/test_output/hello_world.txt
+++ b/examples/hello_world/test_output/hello_world.txt
@@ -1,5 +1,5 @@
[doctest] doctest version is "1.0.0"
-[doctest] run with "-dt-help" for options
+[doctest] run with "--help" for options
===============================================================================
main.cpp(6)
testing the factorial function
@@ -10,5 +10,5 @@ with expansion:
CHECK( 0 == 1 )
===============================================================================
-[doctest] test cases: 1 | 0 passed | 1 failed
-[doctest] assertions: 5 | 4 passed | 1 failed
+[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped
+[doctest] assertions: 5 | 4 passed | 1 failed |
diff --git a/examples/multi_file_example/test_output/multi_file_example.txt b/examples/multi_file_example/test_output/multi_file_example.txt
index fc8d7e2..01ce372 100644
--- a/examples/multi_file_example/test_output/multi_file_example.txt
+++ b/examples/multi_file_example/test_output/multi_file_example.txt
@@ -1,5 +1,14 @@
[doctest] doctest version is "1.0.0"
-[doctest] run with "-dt-help" for options
+[doctest] run with "--help" for options
===============================================================================
-[doctest] test cases: 0 | 0 passed | 0 failed
-[doctest] assertions: 0 | 0 passed | 0 failed
+f1.cpp(3)
+
+
+f1.cpp(4) FAILED!
+ CHECK( 1 == 0 )
+with expansion:
+ CHECK( 1 == 0 )
+
+===============================================================================
+[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped
+[doctest] assertions: 1 | 0 passed | 1 failed |
diff --git a/examples/separate_headers/CMakeLists.txt b/examples/separate_headers/CMakeLists.txt
new file mode 100644
index 0000000..77efa4c
--- /dev/null
+++ b/examples/separate_headers/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 2.8)
+
+get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+project(${PROJECT_NAME})
+
+include(../../scripts/common.cmake)
+
+include_directories("../../doctest/")
+
+add_executable(${PROJECT_NAME} main.cpp test.cpp)
+
+add_test(NAME ${PROJECT_NAME} COMMAND $<TARGET_FILE:${PROJECT_NAME}>)
diff --git a/examples/separate_headers/main.cpp b/examples/separate_headers/main.cpp
new file mode 100644
index 0000000..6345532
--- /dev/null
+++ b/examples/separate_headers/main.cpp
@@ -0,0 +1,21 @@
+#include "parts/doctest_impl.h"
+
+int main(int argc, char** argv) {
+ doctest::Context context(argc, argv); // initialize
+
+ // overrides
+ context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in the name
+ context.setOption("no-breaks", true); // don't break in the debugger when assertions fail
+ context.setOption("abort-after", 5); // stop test execution after 5 failed assertions
+ context.setOption("sort", "name"); // sort the test cases by their name
+
+ int res = context.run(); // run
+
+ if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this
+ return res; // propagate the result of the tests
+
+ int client_stuff_return_code = 0;
+ // your program - if the testing framework is integrated in your production code
+
+ return res + client_stuff_return_code;
+}
diff --git a/examples/separate_headers/test.cpp b/examples/separate_headers/test.cpp
new file mode 100644
index 0000000..7b351de
--- /dev/null
+++ b/examples/separate_headers/test.cpp
@@ -0,0 +1,5 @@
+#include "parts/doctest_fwd.h"
+
+TEST_CASE("captain obvious") {
+ CHECK(true == true);
+}
diff --git a/examples/separate_headers/test_output/separate_headers.txt b/examples/separate_headers/test_output/separate_headers.txt
new file mode 100644
index 0000000..0765785
--- /dev/null
+++ b/examples/separate_headers/test_output/separate_headers.txt
@@ -0,0 +1,5 @@
+[doctest] doctest version is "1.0.0"
+[doctest] run with "--help" for options
+===============================================================================
+[doctest] test cases: 1 | 1 passed | 0 failed | 0 skipped
+[doctest] assertions: 1 | 1 passed | 0 failed |
diff --git a/examples/stringification/test_output/stringification.txt b/examples/stringification/test_output/stringification.txt
index bc380ba..62b65b7 100644
--- a/examples/stringification/test_output/stringification.txt
+++ b/examples/stringification/test_output/stringification.txt
@@ -1,5 +1,5 @@
[doctest] doctest version is "1.0.0"
-[doctest] run with "-dt-help" for options
+[doctest] run with "--help" for options
===============================================================================
main.cpp(86)
the only test
@@ -25,5 +25,5 @@ with expansion:
CHECK( [1, 42, 3, ] == [1, 2, 666, ] )
===============================================================================
-[doctest] test cases: 1 | 0 passed | 1 failed
-[doctest] assertions: 4 | 0 passed | 4 failed
+[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped
+[doctest] assertions: 4 | 0 passed | 4 failed |
diff --git a/examples/subcases_and_bdd/test_output/subcases_and_bdd.txt b/examples/subcases_and_bdd/test_output/subcases_and_bdd.txt
index e1fd3e9..a3661fe 100644
--- a/examples/subcases_and_bdd/test_output/subcases_and_bdd.txt
+++ b/examples/subcases_and_bdd/test_output/subcases_and_bdd.txt
@@ -1,5 +1,5 @@
[doctest] doctest version is "1.0.0"
-[doctest] run with "-dt-help" for options
+[doctest] run with "--help" for options
root
1
@@ -51,5 +51,5 @@ with expansion:
CHECK( 84 == 85 )
===============================================================================
-[doctest] test cases: 4 | 1 passed | 3 failed
-[doctest] assertions: 18 | 15 passed | 3 failed
+[doctest] test cases: 4 | 1 passed | 3 failed | 0 skipped
+[doctest] assertions: 18 | 15 passed | 3 failed |
diff --git a/examples/user_supplied_main/test_output/user_supplied_main.txt b/examples/user_supplied_main/test_output/user_supplied_main.txt
index 8b7f96a..98dc2be 100644
--- a/examples/user_supplied_main/test_output/user_supplied_main.txt
+++ b/examples/user_supplied_main/test_output/user_supplied_main.txt
@@ -1,6 +1,6 @@
[doctest] doctest version is "1.0.0"
-[doctest] run with "-dt-help" for options
+[doctest] run with "--help" for options
===============================================================================
-[doctest] test cases: 1 | 1 passed | 0 failed
-[doctest] assertions: 1 | 1 passed | 0 failed
+[doctest] test cases: 1 | 1 passed | 0 failed | 1 skipped
+[doctest] assertions: 1 | 1 passed | 0 failed |
Program code.