From 180aa5226a1f1a17a259fc811c6570413ea06027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20LAIGRE?= Date: Mon, 28 Feb 2022 12:31:09 +0100 Subject: [PATCH] Improve coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien LAIGRE --- test/iidm/BusBreakerVoltageLevelTest.cpp | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/iidm/BusBreakerVoltageLevelTest.cpp b/test/iidm/BusBreakerVoltageLevelTest.cpp index 75a5350ff..91b43ae46 100644 --- a/test/iidm/BusBreakerVoltageLevelTest.cpp +++ b/test/iidm/BusBreakerVoltageLevelTest.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include #include @@ -491,6 +493,34 @@ BOOST_AUTO_TEST_CASE(TestRemoveVoltageLevel) { POWSYBL_ASSERT_THROW(network.getVoltageLevel("VL2"), PowsyblException, "Unable to find to the identifiable 'VL2'"); } +BOOST_AUTO_TEST_CASE(expandBusBranch) { + Network network = createSwitchBBKNetwork(); + VoltageLevel& voltageLevel = network.getVoltageLevel("VL3"); + Bus& b1 = network.getBusBreakerView().getBus("VL3_BUS1"); + Bus& b2 = network.getBusBreakerView().getBus("VL3_BUS2"); + Bus& b3 = network.getBusBreakerView().getBus("VL3_BUS3"); + Switch& sw1 = network.getSwitch("SW1"); + + std::vector> buses; + voltage_level::BusBreakerView::Traverser traverser = [&buses, &sw1](const Bus& /*bus1*/, const stdcxx::Reference& sw, const Bus& bus2) { + if (sw && stdcxx::areSame(sw.get(), sw1)) { + return math::TraverseResult::TERMINATE_PATH; + } + buses.emplace_back(std::ref(bus2)); + return math::TraverseResult::CONTINUE; + }; + + voltageLevel.getBusBreakerView().traverse(b1, traverser); + BOOST_CHECK_EQUAL(0, buses.size()); + + voltageLevel.getBusBreakerView().traverse(b2, traverser); + BOOST_CHECK(stdcxx::areSame(b3, (*buses.begin()).get())); + + buses.clear(); + voltageLevel.getBusBreakerView().traverse(b3, traverser); + BOOST_CHECK(stdcxx::areSame(b2, (*buses.begin()).get())); +} + BOOST_AUTO_TEST_SUITE_END() } // namespace iidm