From 9ce46f85f77b480d7be238e61dbd11fed932d7ad Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Fri, 13 Dec 2024 16:29:46 +0100 Subject: [PATCH] test param not in model --- .../modelParser/testSystemConverter.cpp | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/tests/src/solver/modelParser/testSystemConverter.cpp b/src/tests/src/solver/modelParser/testSystemConverter.cpp index 4c9d4f2b06..3e160d10f7 100644 --- a/src/tests/src/solver/modelParser/testSystemConverter.cpp +++ b/src/tests/src/solver/modelParser/testSystemConverter.cpp @@ -34,7 +34,7 @@ using namespace std::string_literals; using namespace Antares::Solver; using namespace Antares::Study; -BOOST_AUTO_TEST_CASE(full_model_system) +struct Fixture { ModelParser::Model model1{.id = "node", .description = "description", @@ -45,14 +45,20 @@ BOOST_AUTO_TEST_CASE(full_model_system) .constraints = {{"constraint1", "cost"}}, .objective = ""}; + SystemParser::Parser parser; ModelParser::Library library; - library.id = "std"; - library.models = {model1}; - - SystemModel::Library lib = ModelConverter::convert(library); + SystemModel::Library lib; + Fixture() + { + library.id = "std"; + library.models = {model1}; + lib = ModelConverter::convert(library); + } +}; - SystemParser::Parser parser; +BOOST_FIXTURE_TEST_CASE(full_model_system, Fixture) +{ const auto system = R"( system: id: base_system @@ -78,3 +84,26 @@ BOOST_AUTO_TEST_CASE(full_model_system) BOOST_CHECK_EQUAL(systemModel.Components().at("N").getModel()->Id(), "node"); BOOST_CHECK_EQUAL(systemModel.Components().at("N").getParameterValue("cost"), 30); } + +BOOST_FIXTURE_TEST_CASE(bad_param_name_in_component, Fixture) +{ + const auto system = R"( + system: + id: base_system + description: real application model + model-libraries: [std] + components: + - id: N + model: std.node + scenario-group: group-234 + parameters: + - id: param_not_in_model + type: constant + value: 30 + )"s; + + std::vector libraries = {lib}; + SystemParser::System systemObj = parser.parse(system); + + BOOST_CHECK_THROW(SystemConverter::convert(systemObj, libraries), std::invalid_argument); +}