diff --git a/test/iidm/BusBreakerVoltageLevelTest.cpp b/test/iidm/BusBreakerVoltageLevelTest.cpp index 75a5350f..91b43ae4 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