generated from cpp-best-practices/cmake_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added auto generation of puzzle test files.
- Loading branch information
1 parent
4c47e6e
commit 7bf9a4b
Showing
4 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
set(path ${CMAKE_CURRENT_LIST_DIR}) | ||
cmake_path(GET path FILENAME this_directory) | ||
|
||
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/@dir_name@_test.cpp") | ||
message("Creating standard test file for this days solution.") | ||
configure_file( | ||
"${CMAKE_SOURCE_DIR}/configured_files/day_test.cpp.in" | ||
"${CMAKE_CURRENT_LIST_DIR}/@dir_name@_test.cpp" | ||
@ONLY) | ||
endif() | ||
|
||
add_executable(@parent_directory@_@dir_name@_test @dir_name@_test.cpp | ||
${CMAKE_SOURCE_DIR}/src/campaigns/@parent_directory@/@dir_name@/@parent_directory@_@[email protected]) | ||
|
||
target_link_libraries( | ||
@parent_directory@_@dir_name@_test | ||
PRIVATE AofCode_Cpp::AofCode_Cpp_warnings | ||
AofCode_Cpp::AofCode_Cpp_options | ||
AofCode_Cpp::aoc_library | ||
Catch2::Catch2WithMain) | ||
|
||
if(WIN32 AND BUILD_SHARED_LIBS) | ||
add_custom_command( | ||
TARGET tests | ||
PRE_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:tests> $<TARGET_FILE_DIR:tests> | ||
COMMAND_EXPAND_LISTS) | ||
endif() | ||
|
||
target_include_directories( | ||
@parent_directory@_@dir_name@_test | ||
PRIVATE ${CMAKE_SOURCE_DIR}/src/campaigns/@parent_directory@/@dir_name@) | ||
|
||
# automatically discover tests that are defined in catch based test files you can modify the unittests. Set TEST_PREFIX | ||
# to whatever you want, or use different for different binaries | ||
catch_discover_tests( | ||
@parent_directory@_@dir_name@_test | ||
TEST_PREFIX | ||
"campaign @parent_directory@ @dir_name@ tests: " | ||
REPORTER | ||
XML | ||
OUTPUT_DIR | ||
. | ||
OUTPUT_PREFIX | ||
"campaign @parent_directory@ @dir_name@ tests: " | ||
OUTPUT_SUFFIX | ||
.xml) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <catch2/matchers/catch_matchers_container_properties.hpp> | ||
#include <catch2/matchers/catch_matchers_vector.hpp> | ||
|
||
#include <iostream> | ||
|
||
#include <@parent_directory@_@[email protected]> | ||
|
||
// start with a test case that does nothing but fail. | ||
|
||
TEST_CASE(" @parent_directory@ @dir_name@ testing not started", "[@dir_name@]") | ||
{ | ||
REQUIRE( false ); | ||
} |
This file contains 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