Skip to content

Commit

Permalink
test parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Dec 12, 2024
1 parent 3289a8d commit c884e8f
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion src/tests/src/solver/modelParser/testSystemParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(two_components)
const auto system = R"(
system:
id: base_system
description: one simple component
description: two components
components:
- id: N
model: std.node
Expand All @@ -127,3 +127,56 @@ BOOST_AUTO_TEST_CASE(two_components)
BOOST_CHECK_EQUAL(systemObj.components[1].model, "std.generator");
BOOST_CHECK_EQUAL(systemObj.components[1].scenarioGroup, "group-thermal");
}

BOOST_AUTO_TEST_CASE(component_parameter)
{
SystemParser::Parser parser;
const auto system = R"(
system:
id: base_system
description: one component with one parameter
components:
- id: N
model: std.node
scenario-group: group-234
parameters:
- id: cost
type: constant
value: 30
)"s;
SystemParser::System systemObj = parser.parse(system);
const auto& param = systemObj.components[0].parameters[0];
BOOST_CHECK_EQUAL(param.id, "cost");
BOOST_CHECK_EQUAL(param.type, "constant");
BOOST_CHECK_EQUAL(param.value, "30");
}

BOOST_AUTO_TEST_CASE(component_two_parameters)
{
SystemParser::Parser parser;
const auto system = R"(
system:
id: base_system
description: one component with one parameter
components:
- id: N
model: std.node
scenario-group: group-234
parameters:
- id: cost
type: constant
value: 30
- id: p_max
type: constant
value: 100
)"s;
SystemParser::System systemObj = parser.parse(system);
const auto& param = systemObj.components[0].parameters[0];
const auto& param2 = systemObj.components[0].parameters[1];
BOOST_CHECK_EQUAL(param.id, "cost");
BOOST_CHECK_EQUAL(param.type, "constant");
BOOST_CHECK_EQUAL(param.value, "30");
BOOST_CHECK_EQUAL(param2.id, "p_max");
BOOST_CHECK_EQUAL(param2.type, "constant");
BOOST_CHECK_EQUAL(param2.value, "100");
}

0 comments on commit c884e8f

Please sign in to comment.