Created
November 30, 2018 22:23
-
-
Save apathyboy/ea10322c1a2ce92d4045988e40bfdc55 to your computer and use it in GitHub Desktop.
ctest test explorer issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 3.12 FATAL_ERROR) | |
| if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) | |
| set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") | |
| endif() | |
| project(ctest_issue VERSION 0.1.0) | |
| find_package(Catch2 REQUIRED) | |
| include(CTest) | |
| include(ParseAndAddCatchTests) | |
| # tests | |
| add_executable(ctest_issue tests.cpp) | |
| target_link_libraries(ctest_issue PRIVATE Catch2::Catch2) | |
| ParseAndAddCatchTests(ctest_issue) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file | |
| #include <catch2/catch.hpp> | |
| unsigned int Factorial(unsigned int number) | |
| { | |
| return number <= 1 ? number : Factorial(number - 1) * number; | |
| } | |
| TEST_CASE("Factorials are computed", "[factorial]") | |
| { | |
| REQUIRE(Factorial(1) == 1); | |
| REQUIRE(Factorial(2) == 2); | |
| REQUIRE(Factorial(3) == 6); | |
| REQUIRE(Factorial(10) == 3628800); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment