diff options
author | onqtam <vik.kirilov@gmail.com> | 2017-04-16 22:48:07 +0300 |
---|---|---|
committer | onqtam <vik.kirilov@gmail.com> | 2017-05-16 00:22:20 +0300 |
commit | a985f5a1506f67a3f04202a60af527fb9b5797ee (patch) | |
tree | ad94d6da7bbf7bee936703e202b640765cb1b2bb | |
parent | 2c100d6a80d40acf16493b45568263261d850bd1 (diff) |
added playground project and made (again) the common.cmake behave when included multiple times
-rw-r--r-- | .gitignore | 10 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | scripts/cmake/common.cmake | 5 | ||||
-rw-r--r-- | scripts/playground/CMakeLists.txt | 11 | ||||
-rw-r--r-- | scripts/playground/main.cpp | 30 | ||||
-rw-r--r-- | scripts/playground/test.cpp | 12 | ||||
-rw-r--r-- | scripts/playground/test_output/playground.txt | 13 |
7 files changed, 77 insertions, 6 deletions
@@ -25,11 +25,9 @@ *.s # My garbage :) +Win32/ +x64/ scripts/bench/project/* -build/* -build-mingw/* -examples/*/build/* -examples/*/build-mingw/* -scripts/*/build/* -scripts/*/build-mingw/* +build/ +build-mingw/ *.pyc diff --git a/CMakeLists.txt b/CMakeLists.txt index ccd9f2d..c9f2ece 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,8 @@ if(${DOCTEST_WITH_TESTS}) add_subdirectory(examples/${DIRNAME}) endif() endforeach() + + add_subdirectory(scripts/playground) endif() ################################################################################ diff --git a/scripts/cmake/common.cmake b/scripts/cmake/common.cmake index a00c80f..7dd4015 100644 --- a/scripts/cmake/common.cmake +++ b/scripts/cmake/common.cmake @@ -1,3 +1,8 @@ +if(common_included) + return() +endif() +set(common_included true) + include(CMakeParseArguments) # cache this for use inside of the function diff --git a/scripts/playground/CMakeLists.txt b/scripts/playground/CMakeLists.txt new file mode 100644 index 0000000..c587a8e --- /dev/null +++ b/scripts/playground/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.0) + +project(playground) + +include(../cmake/common.cmake) + +include_directories("../../doctest/") + +doctest_add_executable(${PROJECT_NAME} main.cpp test.cpp) + +doctest_add_test(NAME ${PROJECT_NAME} COMMAND $<TARGET_FILE:${PROJECT_NAME}>) diff --git a/scripts/playground/main.cpp b/scripts/playground/main.cpp new file mode 100644 index 0000000..5da4c16 --- /dev/null +++ b/scripts/playground/main.cpp @@ -0,0 +1,30 @@ +#include "parts/doctest_impl.h" + +int main(int argc, char** argv) { + doctest::Context context; + + // !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!! + + // defaults + 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.applyCommandLine(argc, argv); + + // overrides + context.setOption("order-by", "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 + +#ifdef WITH_PAUSE + system("pause"); +#endif // WITH_PAUSE + + return res + client_stuff_return_code; // the result from doctest is propagated here as well +} diff --git a/scripts/playground/test.cpp b/scripts/playground/test.cpp new file mode 100644 index 0000000..c19579c --- /dev/null +++ b/scripts/playground/test.cpp @@ -0,0 +1,12 @@ +#include "parts/doctest_fwd.h" + +#include <iostream> +using namespace std; + +//static int throws(bool in) { if(in) throw 42; return 0; } + +TEST_CASE("dev stuff") { + CHECK(4 == 5); + //CHECK_THROWS(CHECK_THROWS(4 == 5)); + //CHECK_THROWS({throws(true);}); +} diff --git a/scripts/playground/test_output/playground.txt b/scripts/playground/test_output/playground.txt new file mode 100644 index 0000000..0266018 --- /dev/null +++ b/scripts/playground/test_output/playground.txt @@ -0,0 +1,13 @@ +[doctest] run with "--help" for options +== TEST CASE ================================================================== +test.cpp(0) +dev stuff + +test.cpp(0) ERROR! + CHECK( 4 == 5 ) +with expansion: + CHECK( 4 == 5 ) + +=============================================================================== +[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped +[doctest] assertions: 1 | 0 passed | 1 failed | |