Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Dec 12, 2024
1 parent 7380bbb commit 5757d2c
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions src/tests/src/solver/modelParser/testSystemParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,66 @@
using namespace std::string_literals;
using namespace Antares::Solver;

BOOST_AUTO_TEST_CASE(EmptySystem)
BOOST_AUTO_TEST_CASE(empty_system)
{
SystemParser::Parser parser;
const auto system = R"(
system:
id: ""
description: ""
port-types: []
models: []
model-libraries: []
components: []
)"s;
SystemParser::System systemObj = parser.parse(system);
BOOST_CHECK(systemObj.id.empty());
BOOST_CHECK(systemObj.libraries.empty());
BOOST_CHECK(systemObj.components.empty());
}

BOOST_AUTO_TEST_CASE(simple_id)
{
SystemParser::Parser parser;
const auto system = R"(
system:
id: base_system
description: a basic system
model-libraries: []
components: []
)"s;
SystemParser::System systemObj = parser.parse(system);
BOOST_CHECK_EQUAL(systemObj.id, "base_system");
BOOST_CHECK(systemObj.libraries.empty());
BOOST_CHECK(systemObj.components.empty());
}

BOOST_AUTO_TEST_CASE(libraries_one_model)
{
SystemParser::Parser parser;
const auto system = R"(
system:
id: base_system
description: a basic system
model-libraries: [abc]
components: []
)"s;
SystemParser::System systemObj = parser.parse(system);
BOOST_CHECK_EQUAL(systemObj.libraries[0], "abc");
BOOST_CHECK(systemObj.components.empty());
}

BOOST_AUTO_TEST_CASE(libraries_list_of_models)
{
SystemParser::Parser parser;
const auto system = R"(
system:
id: base_system
description: a basic system
model-libraries: [abc, def, 123]
components: []
)"s;
SystemParser::System systemObj = parser.parse(system);
BOOST_CHECK_EQUAL(systemObj.libraries[0], "abc");
BOOST_CHECK_EQUAL(systemObj.libraries[1], "def");
BOOST_CHECK_EQUAL(systemObj.libraries[2], "123");
BOOST_CHECK(systemObj.components.empty());
}

0 comments on commit 5757d2c

Please sign in to comment.