Commit 27822aac authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1272 Reactivate InputData test.

parent 3deeaab2
......@@ -8,9 +8,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/Now/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/PrintContainer/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/Filesystem/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/StrongType/CMakeLists.txt)
# Needs to be incorporated (or dropped) - see #1272
# include(${CMAKE_CURRENT_LIST_DIR}/InputData/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/InputData/CMakeLists.txt)
......
......@@ -6,5 +6,9 @@ add_executable(MoReFEMTestInputData
target_link_libraries(MoReFEMTestInputData
${MOREFEM_TEST_TOOLS})
add_test(TestInputData MoReFEMTestInputData)
add_test(TestInputData MoReFEMTestInputData
--
${MOREFEM_ROOT}
${MOREFEM_TEST_OUTPUT_DIR})
set_tests_properties(TestInputData PROPERTIES TIMEOUT 20)
......@@ -7,84 +7,63 @@
//
*/
#define BOOST_TEST_MODULE input_data
#include "ThirdParty/IncludeWithoutWarning/Boost/Test.hpp"
#include <cstdlib>
#include "Utilities/Exceptions/PrintAndAbort.hpp"
#include "Utilities/String/String.hpp"
#include "Core/MoReFEMData/MoReFEMData.hpp"
#include "Test/Utilities/InputData/InputData.hpp"
#include "Test/Tools/InitializeTestMoReFEMData.hpp"
#include "Test/Tools/Fixture/Environment.hpp"
using namespace MoReFEM;
PRAGMA_DIAGNOSTIC(push)
#include "Utilities/Warnings/Internal/IgnoreWarning/disabled-macro-expansion.hpp"
int main(int argc, char** argv)
BOOST_FIXTURE_TEST_CASE(properly_read, ::MoReFEM::TestNS::FixtureNS::Environment)
{
using namespace MoReFEM;
//! \copydoc doxygen_hide_model_specific_input_data
using InputData = TestNS::ReadInputDataNS::InputData;
try
decltype(auto) environment = Utilities::Environment::CreateOrGetInstance(__FILE__, __LINE__);
TestNS::InitializeTestMoReFEMData<InputData>
init(environment.SubstituteValues("${MOREFEM_ROOT}/Sources/Test/Utilities/InputData/"
"demo_input_parameter_test_ipl.lua"));
decltype(auto) morefem_data = init.GetMoReFEMData();
decltype(auto) input_data = morefem_data.GetInputData();
namespace ipl = Utilities::InputDataNS;
{
MoReFEMData<InputData, program_type::test> morefem_data(argc, argv);
const auto& input_data = morefem_data.GetInputData();
const auto& mpi = morefem_data.GetMpi();
try
{
namespace ipl = Utilities::InputDataNS;
{
using NS = InputDataNS::NumberingSubset<1>;
decltype(auto) value = ipl::Extract<NS::Name>::Value(input_data);
if (value != "Numbering subset")
throw Exception("Field related to numbering subset not read correctly",
__FILE__, __LINE__);
}
{
using interp_type = InputDataNS::InterpolationFile;
decltype(auto) value = ipl::Extract<interp_type>::Value(input_data);
if (value != "${MOREFEM_ROOT}/Data/Interpolation/Poromechanics/Identity_6x6.hhdata")
throw Exception("Field related to interpolation file not read correctly.",
__FILE__, __LINE__);
decltype(auto) path = ipl::Extract<interp_type>::Path(input_data);
if (!Utilities::String::EndsWith(path, "Data/Interpolation/Poromechanics/Identity_6x6.hhdata")
|| path.find("${MOREFEM_ROOT}") != std::string::npos)
throw Exception("Field related to interpolation file not read correctly regarding its environment variable.",
__FILE__, __LINE__);
}
}
catch(const std::exception& e)
{
ExceptionNS::PrintAndAbort(mpi, e.what());
}
using NS = InputDataNS::NumberingSubset<1>;
decltype(auto) value = ipl::Extract<NS::Name>::Value(input_data);
BOOST_CHECK_EQUAL(value, "Numbering subset");
}
catch(const ExceptionNS::GracefulExit&)
using interp_type = InputDataNS::InterpolationFile;
{
return EXIT_SUCCESS;
decltype(auto) value = ipl::Extract<interp_type>::Value(input_data);
BOOST_CHECK_EQUAL(value, "${MOREFEM_ROOT}/Data/Interpolation/Poromechanics/Identity_6x6.hhdata");
}
catch(const std::exception& e)
{
std::ostringstream oconv;
oconv << "Exception caught from MoReFEMData<InputData>: " << e.what() << std::endl;
std::cout << oconv.str();
return EXIT_FAILURE;
decltype(auto) path = ipl::Extract<interp_type>::Path(input_data);
BOOST_CHECK(Utilities::String::EndsWith(path, "Data/Interpolation/Poromechanics/Identity_6x6.hhdata")
|| path.find("${MOREFEM_ROOT}") == std::string::npos);
}
return EXIT_SUCCESS;
}
PRAGMA_DIAGNOSTIC(pop)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment