From 26cd32e4f06646cfa11dc234cf4c09c380666e04 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 5 Dec 2024 13:07:49 +0100 Subject: [PATCH] add unit tests --- .../study/parameters/parameters-tests.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/tests/src/libs/antares/study/parameters/parameters-tests.cpp b/src/tests/src/libs/antares/study/parameters/parameters-tests.cpp index 5e0da57a10..6015fcbbc0 100644 --- a/src/tests/src/libs/antares/study/parameters/parameters-tests.cpp +++ b/src/tests/src/libs/antares/study/parameters/parameters-tests.cpp @@ -104,6 +104,26 @@ BOOST_FIXTURE_TEST_CASE(invalidValues, Fixture) BOOST_CHECK_EQUAL(p.renewableGeneration(), rgUnknown); } +BOOST_FIXTURE_TEST_CASE(hydroPmax, Fixture) +{ + BOOST_CHECK(p.compatibility.hydroPmax == Parameters::Compatibility::HydroPmax::Daily); + + writeValidFile(); + BOOST_CHECK(p.loadFromFile(path.string(), version)); + p.validateOptions(options); + p.fixBadValues(); + + BOOST_CHECK(p.compatibility.hydroPmax == Parameters::Compatibility::HydroPmax::Hourly); + + BOOST_CHECK_EQUAL(CompatibilityHydroPmaxToCString(p.compatibility.hydroPmax), "hourly"); + BOOST_CHECK_EQUAL(CompatibilityHydroPmaxToCString(Parameters::Compatibility::HydroPmax::Daily), + "daily"); + + BOOST_CHECK(StringToCompatibilityHydroPmax(p.compatibility.hydroPmax, "daily")); + BOOST_CHECK(!StringToCompatibilityHydroPmax(p.compatibility.hydroPmax, "")); + BOOST_CHECK(!StringToCompatibilityHydroPmax(p.compatibility.hydroPmax, "abc")); +} + BOOST_AUTO_TEST_SUITE_END() void Fixture::writeInvalidFile() @@ -215,7 +235,10 @@ void Fixture::writeValidFile() seed-spilled-energy-costs = 7005489 seed-thermal-costs = 8005489 seed-hydro-costs = 9005489 - seed-initial-reservoir-levels = 10005489)"; + seed-initial-reservoir-levels = 10005489 + + [compatibility] + hydro-pmax = hourly)"; outfile.close(); }