Skip to content

Commit

Permalink
test param not in model
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Dec 13, 2024
1 parent 55fc259 commit 9ce46f8
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions src/tests/src/solver/modelParser/testSystemConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand All @@ -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<SystemModel::Library> libraries = {lib};
SystemParser::System systemObj = parser.parse(system);

BOOST_CHECK_THROW(SystemConverter::convert(systemObj, libraries), std::invalid_argument);
}

0 comments on commit 9ce46f8

Please sign in to comment.