-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a unit test of one of the important YamlHelper functions
- Loading branch information
Luke Pickering
committed
Oct 30, 2024
1 parent
d442469
commit 5ab2064
Showing
4 changed files
with
39 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ set(MaCh3_VERSION ${PROJECT_VERSION}) | |
#LP - This option name is confusing, but I wont change it now. | ||
option(USE_CPU "Whether to *only* use the CPU (i.e. no GPU)" OFF) | ||
option(MaCh3_PYTHON_ENABLED "Whether to build MaCh3 python bindings" OFF) | ||
option(MaCh3_TESTS_ENABLED "Whether to build MaCh3 unit tests" OFF) | ||
|
||
# Try to find CUDA | ||
find_package(CUDAToolkit QUIET) | ||
|
@@ -326,3 +327,17 @@ endif() | |
|
||
# KS: Configure the Doxygen input file, this is to ensure whenever we update MaCh3 version Doxyfile will have same version. | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/Doc/Doxyfile @ONLY) | ||
|
||
|
||
if(MaCh3_TESTS_ENABLED) | ||
find_package(Catch2) | ||
if(NOT Catch2_FOUND) | ||
CPMAddPackage("gh:catchorg/[email protected]") | ||
LIST(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras) | ||
endif() | ||
|
||
include(CTest) | ||
include(Catch) | ||
|
||
add_subdirectory(tests) | ||
endif() |
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,4 @@ | ||
add_executable(manager_tests manager_tests.cpp) | ||
target_link_libraries(manager_tests PRIVATE Catch2::Catch2WithMain Manager) | ||
|
||
catch_discover_tests(manager_tests) |
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,18 @@ | ||
#include "catch2/catch_test_macros.hpp" | ||
|
||
#include "manager/YamlHelper.h" | ||
|
||
TEST_CASE("OverrideConfig", "[Yamlhelper]") { | ||
YAML::Node lineup = YAML::Load("{1B: Prince Fielder, 2B: Rickie Weeks, LF: Ryan Braun}"); | ||
|
||
REQUIRE(lineup.size() == 3); | ||
REQUIRE(lineup["1B"].as<std::string>() == "Prince Fielder"); | ||
|
||
OverrideConfig(lineup, "1B", "Fielder formerly know as Prince"); | ||
|
||
REQUIRE(lineup["1B"].as<std::string>() == "Fielder formerly know as Prince"); | ||
|
||
OverrideConfig(lineup, "1B", 123); | ||
|
||
REQUIRE(lineup["1B"].as<unsigned>() == 123u); | ||
} |