Skip to content

Commit

Permalink
Unit test for reverse calculation (#2483)
Browse files Browse the repository at this point in the history
Add new test checks the behavior of the `thermal_cluster` when the
generation behavior is forced to no generation.
Verify the `thermal_cluster` behavior when `tsGenBehavior` is set to
`LocalTSGenerationBehavior::forceNoGen` and the time series is filled
with a constant value.

---------

Co-authored-by: Jason Marechal <[email protected]>
Co-authored-by: Florian OMNES <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2024
1 parent 44228f5 commit cf653e7
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions src/tests/src/libs/antares/study/test_study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,51 @@ struct ThermalClusterStudy: public OneAreaStudy
BOOST_FIXTURE_TEST_CASE(thermal_cluster_rename, ThermalClusterStudy)
{
BOOST_CHECK(study->clusterRename(cluster, "Renamed"));
BOOST_CHECK(cluster->name() == "Renamed");
BOOST_CHECK(cluster->id() == "renamed");
BOOST_CHECK_EQUAL(cluster->name(), "Renamed");
BOOST_CHECK_EQUAL(cluster->id(), "renamed");
}

BOOST_FIXTURE_TEST_CASE(thermal_cluster_delete, ThermalClusterStudy)
{
// gp : remove() only used in GUI (will go away when removing the GUI)
BOOST_CHECK(areaA->thermal.list.findInAll("cluster") == cluster);
BOOST_CHECK_EQUAL(areaA->thermal.list.findInAll("cluster"), cluster);
areaA->thermal.list.remove("cluster");
BOOST_CHECK(areaA->thermal.list.findInAll("cluster") == nullptr);
BOOST_CHECK_EQUAL(areaA->thermal.list.findInAll("cluster"), nullptr);
BOOST_CHECK(areaA->thermal.list.empty());
}

// Custom macro
#define BOOST_CHECK_EQUAL_MESSAGE(L, R, M) \
{ \
BOOST_TEST_INFO(M); \
BOOST_CHECK_EQUAL(L, R); \
}

BOOST_FIXTURE_TEST_CASE(WithForceNoGenOptionTimeSeriesNotGeneratedForReverseSpinning,
ThermalClusterStudy)
{
cluster->tsGenBehavior = LocalTSGenerationBehavior::forceNoGen;
cluster->spinning = 0.9; // An arbitrary value != 1.0 is chosen here, otherwise the reverse
// calculation of spinning does nothing
auto& ts = cluster->series.timeSeries;

ts.resize(1, 8760);
ts.fill(100);
cluster->reverseCalculationOfSpinning();

for (unsigned i = 0; i < ts.width; ++i)
{
for (unsigned j = 0; j < ts.height; ++j)
{
BOOST_CHECK_EQUAL_MESSAGE(ts[i][j],
100,
"Error at " + std::to_string(i) + ", " + std::to_string(j));
}
}
}

#undef BOOST_CHECK_EQUAL_MESSAGE

BOOST_AUTO_TEST_SUITE_END() // thermal clusters

BOOST_AUTO_TEST_SUITE(renewable_clusters_operations)
Expand Down

0 comments on commit cf653e7

Please sign in to comment.