-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
146 additions
and
27 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
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
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
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
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
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,36 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
include(CTest) | ||
|
||
set(project_test "SpinWalk_test") | ||
project(${project_test}) | ||
|
||
# Boost | ||
if(CMAKE_VERSION VERSION_GREATER "3.30") | ||
cmake_policy(SET CMP0167 NEW) | ||
endif() | ||
find_package(Boost REQUIRED COMPONENTS unit_test_framework log) | ||
|
||
if (NOT Boost_UNIT_TEST_FRAMEWORK_FOUND) | ||
message("Boost Unit Test Framework not found. Not compiling tests") | ||
return() | ||
endif () | ||
|
||
if (NOT Boost_USE_STATIC_LIBS) | ||
add_definitions(-DBOOST_TEST_DYN_LINK) | ||
endif() | ||
|
||
|
||
# include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include ${Boost_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | ||
include_directories(${Boost_INCLUDE_DIRS}) | ||
|
||
add_executable(${project_test} test_phantom.cpp test_config.cpp) | ||
target_link_libraries(${project_test} ${Boost_LIBRARIES} SpinWalk_lib) | ||
set_target_properties(${project_test} PROPERTIES OUTPUT_NAME "spinwalk_test") | ||
|
||
add_test(NAME check COMMAND spinwalk_test) | ||
|
||
if (UNIX) | ||
install(TARGETS ${project_test} DESTINATION bin) | ||
endif() | ||
|
||
# spinwalk_test --log_level=test_suite --report_level=short |
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,34 @@ | ||
#define BOOST_TEST_MODULE "SpinWlkTest" | ||
#include <boost/test/unit_test.hpp> | ||
#include <boost/log/core.hpp> | ||
#include <filesystem> | ||
|
||
#include "../src/config/config_generator.h" | ||
#include "../include/ini.h" | ||
|
||
|
||
BOOST_AUTO_TEST_CASE(config_creation) { | ||
boost::log::core::get()->set_logging_enabled(false); | ||
|
||
std::filesystem::path temp_dir = std::filesystem::temp_directory_path(); | ||
std::filesystem::path temp_file = temp_dir / "gre.ini"; | ||
std::filesystem::path temp_file_parent = temp_dir / "default_config.ini"; | ||
std::vector<std::string> phantoms = {"phantom1.h5", "phantom2.h5"}; | ||
uint32_t timestep_us = 25; | ||
uint32_t TE = 12345; | ||
|
||
BOOST_REQUIRE(config::generate_gre(TE, timestep_us, phantoms, temp_file.string())); | ||
BOOST_REQUIRE(std::filesystem::exists(temp_file)); | ||
BOOST_REQUIRE(std::filesystem::exists(temp_file_parent)); | ||
|
||
mINI::INIFile file(temp_file.string()); | ||
mINI::INIStructure ini; | ||
BOOST_REQUIRE(file.read(ini)); | ||
BOOST_CHECK_EQUAL(std::stoi(ini["SCAN_PARAMETERS"]["TE[0]"]), TE); | ||
BOOST_CHECK_EQUAL(std::stoi(ini["SCAN_PARAMETERS"]["TIME_STEP"]), timestep_us); | ||
|
||
std::filesystem::remove(temp_file); | ||
std::filesystem::remove(temp_file_parent); | ||
BOOST_CHECK(!std::filesystem::exists(temp_file)); | ||
BOOST_CHECK(!std::filesystem::exists(temp_file_parent)); | ||
} |
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,42 @@ | ||
#include <boost/test/unit_test.hpp> | ||
#include <boost/log/core.hpp> | ||
|
||
#include "../src/phantom/phantom_sphere.h" | ||
#include "../src/phantom/phantom_cylinder.h" | ||
|
||
|
||
BOOST_AUTO_TEST_SUITE(test_phantom_creation) | ||
|
||
BOOST_AUTO_TEST_CASE(cylinder_creation) { | ||
boost::log::core::get()->set_logging_enabled(false); | ||
float diff_margin = 2.f; | ||
|
||
std::vector<float> volume_fraction = {5.0, 10.0}; | ||
for(const auto &vf : volume_fraction){ | ||
phantom::cylinder cyl(600, 300, 0.11e-6, -1, -20, vf, 0, 0, ""); | ||
BOOST_TEST(cyl.run(false)); | ||
BOOST_TEST(std::abs(cyl.get_actual_volume_fraction() - vf) < diff_margin); | ||
} | ||
|
||
std::vector<float> angles = {5.0, 10.0}; | ||
float vf = 10.0; | ||
for(const auto &a : angles){ | ||
phantom::cylinder cyl(600, 300, 0.11e-6, -1, -20, vf, 0, a, ""); | ||
BOOST_TEST(cyl.run(false)); | ||
BOOST_TEST(std::abs(cyl.get_actual_volume_fraction() - vf) < diff_margin); | ||
} | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(sphere_creation) { | ||
boost::log::core::get()->set_logging_enabled(false); | ||
std::vector<float> volume_fraction = {5.0, 10.0}; | ||
float diff_margin = 2.f; | ||
for(const auto &vf : volume_fraction){ | ||
phantom::sphere sph(600, 300, 0.11e-6, -1, -20, vf, 0, ""); | ||
BOOST_CHECK(sph.run(false)); | ||
BOOST_CHECK(std::abs(sph.get_actual_volume_fraction() - vf) < diff_margin); | ||
} | ||
} | ||
|
||
|
||
BOOST_AUTO_TEST_SUITE_END() |