Merge branch 'fix-pipeline' into 'csv-to-eigen'

Fix handling of CSV file

See merge request naaice/tug!8
This commit is contained in:
Hannes Martin Signer 2023-08-03 11:12:03 +02:00
commit bc9e92e3ef
3 changed files with 19 additions and 5 deletions

View File

@ -14,6 +14,13 @@ endif()
add_executable(testTug setup.cpp testBoundaryCondition.cpp testDiffusion.cpp testSimulation.cpp)
target_link_libraries(testTug doctest tug)
# get relative path of the CSV file
get_filename_component(testSimulationCSV "FTCS_11_11_7000.csv" REALPATH CACHE)
# set relative path in header file
configure_file(testSimulation.hpp.in testSimulation.hpp)
# include test directory with generated header file from above
target_include_directories(testTug PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_target(
check
COMMAND $<TARGET_FILE:testTug>

View File

@ -1,11 +1,11 @@
#include <stdio.h>
#include <doctest/doctest.h>
#include <tug/Simulation.hpp>
#include <filesystem>
#include "TestUtils.cpp"
#include <string>
namespace fs = std::filesystem;
// include the configured header file
#include <testSimulation.hpp>
static Grid setupSimulation() {
int row = 11;
@ -58,10 +58,10 @@ static Grid setupSimulation() {
}
TEST_CASE("equality to reference matrix") {
fs::path p = fs::current_path(); // .parent_path().parent_path();
string test_path = p.generic_string() + "/FTCS_11_11_7000.csv";
// set string from the header file
string test_path = testSimulationCSVDir;
MatrixXd reference = CSV2Eigen(test_path);
cout << test_path << endl;
Grid grid = setupSimulation();
CHECK(checkSimilarity(reference, grid.getConcentrations(), 0.1) == true);
}
}

View File

@ -0,0 +1,7 @@
#ifndef TESTSIMULATION_H_
#define TESTSIMULATION_H_
// CSV file needed for validation
const char *testSimulationCSVDir = "@testSimulationCSV@";
#endif // TESTSIMULATION_H_