From 2fb43d61807dae89f604fb9d58e9df036dc61d01 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 19 Dec 2024 14:31:21 +0100 Subject: [PATCH] Add unit test folder --- src/solver/modeler/loadFiles/CMakeLists.txt | 10 ++-- .../{ => modeler}/loadFiles/loadFiles.h | 0 .../modeler/loadFiles/readLibraries.cpp | 2 +- src/solver/modeler/loadFiles/readSystem.cpp | 2 +- src/tests/src/solver/modeler/CMakeLists.txt | 1 + .../solver/modeler/loadFiles/CMakeLists.txt | 14 +++++ .../loadFiles/testLoadModelerFiles.cpp | 54 +++++++++++++++++++ 7 files changed, 77 insertions(+), 6 deletions(-) rename src/solver/modeler/loadFiles/include/antares/solver/{ => modeler}/loadFiles/loadFiles.h (100%) create mode 100644 src/tests/src/solver/modeler/loadFiles/CMakeLists.txt create mode 100644 src/tests/src/solver/modeler/loadFiles/testLoadModelerFiles.cpp diff --git a/src/solver/modeler/loadFiles/CMakeLists.txt b/src/solver/modeler/loadFiles/CMakeLists.txt index 81a507a8f5..54ebf5b3e3 100644 --- a/src/solver/modeler/loadFiles/CMakeLists.txt +++ b/src/solver/modeler/loadFiles/CMakeLists.txt @@ -1,20 +1,22 @@ set(SOURCES readSystem.cpp readLibraries.cpp + + include/antares/solver/modeler/loadFiles/loadFiles.h ) # Create the library -add_library(loadFiles STATIC ${SOURCES}) -add_library(Antares::loadFiles ALIAS loadFiles) +add_library(loadModelerFiles STATIC ${SOURCES}) +add_library(Antares::loadModelerFiles ALIAS loadModelerFiles) # Specify include directories -target_include_directories(loadFiles +target_include_directories(loadModelerFiles PUBLIC $ ) # Link dependencies (if any) -target_link_libraries(loadFiles +target_link_libraries(loadModelerFiles PUBLIC Antares::antares-study-system-model PRIVATE diff --git a/src/solver/modeler/loadFiles/include/antares/solver/loadFiles/loadFiles.h b/src/solver/modeler/loadFiles/include/antares/solver/modeler/loadFiles/loadFiles.h similarity index 100% rename from src/solver/modeler/loadFiles/include/antares/solver/loadFiles/loadFiles.h rename to src/solver/modeler/loadFiles/include/antares/solver/modeler/loadFiles/loadFiles.h diff --git a/src/solver/modeler/loadFiles/readLibraries.cpp b/src/solver/modeler/loadFiles/readLibraries.cpp index 432385041c..d71615f080 100644 --- a/src/solver/modeler/loadFiles/readLibraries.cpp +++ b/src/solver/modeler/loadFiles/readLibraries.cpp @@ -23,7 +23,7 @@ #include #include #include -#include "antares/solver/loadFiles/loadFiles.h" +#include "antares/solver/modeler/loadFiles/loadFiles.h" namespace fs = std::filesystem; diff --git a/src/solver/modeler/loadFiles/readSystem.cpp b/src/solver/modeler/loadFiles/readSystem.cpp index 040860fa3e..f51f5d83d1 100644 --- a/src/solver/modeler/loadFiles/readSystem.cpp +++ b/src/solver/modeler/loadFiles/readSystem.cpp @@ -22,7 +22,7 @@ #include #include #include -#include "antares/solver/loadFiles/loadFiles.h" +#include "antares/solver/modeler/loadFiles/loadFiles.h" namespace fs = std::filesystem; diff --git a/src/tests/src/solver/modeler/CMakeLists.txt b/src/tests/src/solver/modeler/CMakeLists.txt index 53d257b04e..d532a0a77d 100644 --- a/src/tests/src/solver/modeler/CMakeLists.txt +++ b/src/tests/src/solver/modeler/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory(api) +add_subdirectory(loadFiles) diff --git a/src/tests/src/solver/modeler/loadFiles/CMakeLists.txt b/src/tests/src/solver/modeler/loadFiles/CMakeLists.txt new file mode 100644 index 0000000000..81bbf085cc --- /dev/null +++ b/src/tests/src/solver/modeler/loadFiles/CMakeLists.txt @@ -0,0 +1,14 @@ +add_executable(load-modeler-files + testLoadModelerFiles.cpp) + +target_link_libraries(load-modeler-files + PRIVATE + Boost::unit_test_framework + Antares::loadModelerFiles + test_utils_unit +) + +set_target_properties(load-modeler-files PROPERTIES FOLDER Unit-tests/test-writer) + +add_test(NAME load-modeler-files COMMAND load-modeler-files) +set_tests_properties(load-modeler-files PROPERTIES LABELS unit) diff --git a/src/tests/src/solver/modeler/loadFiles/testLoadModelerFiles.cpp b/src/tests/src/solver/modeler/loadFiles/testLoadModelerFiles.cpp new file mode 100644 index 0000000000..8512eeba33 --- /dev/null +++ b/src/tests/src/solver/modeler/loadFiles/testLoadModelerFiles.cpp @@ -0,0 +1,54 @@ +/* + * Copyright 2007-2024, RTE (https://www.rte-france.com) + * See AUTHORS.txt + * SPDX-License-Identifier: MPL-2.0 + * This file is part of Antares-Simulator, + * Adequacy and Performance assessment for interconnected energy networks. + * + * Antares_Simulator is free software: you can redistribute it and/or modify + * it under the terms of the Mozilla Public Licence 2.0 as published by + * the Mozilla Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Antares_Simulator is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Mozilla Public Licence 2.0 for more details. + * + * You should have received a copy of the Mozilla Public Licence 2.0 + * along with Antares_Simulator. If not, see . + */ +#define WIN32_LEAN_AND_MEAN + +#include +#define BOOST_TEST_MODULE load modeler files + +#include + +#include + +#include "files-system.h" + +BOOST_AUTO_TEST_SUITE(read_modeler_parameters) + +BOOST_AUTO_TEST_CASE(all_properties_set) +{ + /* const auto working_tmp_dir = CREATE_TMP_DIR_BASED_ON_TEST_NAME(); */ + /* const auto fileP = working_tmp_dir / "parameters.yaml"; */ + /* { */ + /* std::ofstream param(fileP); */ + /* param << R"( */ + /* solver: sirius */ + /* solver-logs: false */ + /* solver-parameters: PRESOLVE 1 */ + /* no-output: true)"; */ + /* } */ + + /* auto params = Antares::Solver::parseModelerParameters(fileP); */ + /* BOOST_CHECK_EQUAL(params.solver, "sirius"); */ + /* BOOST_CHECK_EQUAL(params.solverLogs, false); */ + /* BOOST_CHECK_EQUAL(params.solverParameters, "PRESOLVE 1"); */ + /* BOOST_CHECK_EQUAL(params.noOutput, true); */ +} + +BOOST_AUTO_TEST_SUITE_END()