diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d90ab4a174a98711d14a31c2c9fb6209da5316c..8d76b3f97cba2af46ffc9162fa5add4ef0a0e537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,18 @@ include_directories(src/scheme) include_directories(src/experimental) + +# Pastis tests + +set(CATCH_MODULE_PATH "${PASTIS_SOURCE_DIR}/packages/Catch2") +set(CATCH_INCLUDE_PATH "${CATCH_MODULE_PATH}/single_include") + +include("${CATCH_MODULE_PATH}/contrib/ParseAndAddCatchTests.cmake") +add_subdirectory("${CATCH_MODULE_PATH}") + +add_subdirectory(tests) +enable_testing() + # ----------------------------------------------------- link_libraries("-rdynamic") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f62f6d02ef9aaefba38cf845665d12270e463a9e --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,22 @@ +include_directories("${CATCH_INCLUDE_PATH}") + +#set(EXECUTABLE_OUTPUT_PATH ${PASTIS_BINARY_DIR}) +add_executable (unit_tests + main.cpp + example.cpp + example2.cpp) + +target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) +target_link_libraries (unit_tests Catch) + +enable_testing() + +#parse catch tests +ParseAndAddCatchTests (unit_tests) + +#add_dependencies(check +# DEPENDS exec_tests) + +add_custom_target(check + COMMAND unit_tests + DEPENDS unit_tests) diff --git a/tests/example.cpp b/tests/example.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0cbc903b5551a10d3ad3e76bd09972acf382a0ce --- /dev/null +++ b/tests/example.cpp @@ -0,0 +1,19 @@ +#include <catch.hpp> + +TEST_CASE("Test1", "[unit]") { + int a = 1; + int b = 2; + REQUIRE(a == b); +} + +TEST_CASE("Test2") { + int a = 2; + int b = 2; + REQUIRE(a == b); +} + +TEST_CASE("Test3", "[a][b][c]") { + int a = 1; + int b = 2; + REQUIRE(a != b); +} diff --git a/tests/example2.cpp b/tests/example2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..076fa584044eda8a07bfe603f55e612ee603dc27 --- /dev/null +++ b/tests/example2.cpp @@ -0,0 +1,19 @@ +#include <catch.hpp> + +TEST_CASE("Test5", "[unit]") { + int a = 1; + int b = 2; + REQUIRE(a+1 == b); +} + +TEST_CASE("Test6", "[a]") { + int a = 2; + int b = 2; + REQUIRE(a == b); +} + +TEST_CASE("Test7", "[a][b][c]") { + int a = 1; + int b = 2; + REQUIRE(a != b); +} diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7253fe66f48946f0165430bfa61ce733b8c5a7d6 --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,9 @@ +#define CATCH_CONFIG_MAIN +#include <catch.hpp> +// #define CATCH_CONFIG_RUNNER +// #include <catch.hpp> + +// int main(int argc, char* argv[]) { +// auto result = Catch::Session().run(argc, argv); +// return (result < 0xff ? result : 0xff); +// }