Skip to content

Commit

Permalink
Add unit test folder
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Dec 19, 2024
1 parent 67c3754 commit 2fb43d6
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/solver/modeler/loadFiles/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

# Link dependencies (if any)
target_link_libraries(loadFiles
target_link_libraries(loadModelerFiles
PUBLIC
Antares::antares-study-system-model
PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion src/solver/modeler/loadFiles/readLibraries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <antares/logs/logs.h>
#include <antares/solver/modelConverter/modelConverter.h>
#include <antares/solver/modelParser/parser.h>
#include "antares/solver/loadFiles/loadFiles.h"
#include "antares/solver/modeler/loadFiles/loadFiles.h"

namespace fs = std::filesystem;

Expand Down
2 changes: 1 addition & 1 deletion src/solver/modeler/loadFiles/readSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <antares/io/file.h>
#include <antares/solver/systemParser/converter.h>
#include <antares/solver/systemParser/parser.h>
#include "antares/solver/loadFiles/loadFiles.h"
#include "antares/solver/modeler/loadFiles/loadFiles.h"

namespace fs = std::filesystem;

Expand Down
1 change: 1 addition & 0 deletions src/tests/src/solver/modeler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(api)
add_subdirectory(loadFiles)
14 changes: 14 additions & 0 deletions src/tests/src/solver/modeler/loadFiles/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
54 changes: 54 additions & 0 deletions src/tests/src/solver/modeler/loadFiles/testLoadModelerFiles.cpp
Original file line number Diff line number Diff line change
@@ -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 <https://opensource.org/license/mpl-2-0/>.
*/
#define WIN32_LEAN_AND_MEAN

#include <fstream>
#define BOOST_TEST_MODULE load modeler files

#include <boost/test/unit_test.hpp>

#include <antares/solver/modeler/loadFiles/loadFiles.h>

#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()

0 comments on commit 2fb43d6

Please sign in to comment.