Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Sébastien LAIGRE <[email protected]>
  • Loading branch information
sebalaig committed Feb 28, 2022
1 parent 5335cee commit 180aa52
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/iidm/BusBreakerVoltageLevelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
#include <boost/test/unit_test.hpp>

#include <powsybl/iidm/Bus.hpp>
#include <powsybl/iidm/Generator.hpp>
#include <powsybl/iidm/LineAdder.hpp>
#include <powsybl/iidm/Load.hpp>
#include <powsybl/iidm/LoadAdder.hpp>
#include <powsybl/iidm/Network.hpp>
#include <powsybl/iidm/Substation.hpp>
#include <powsybl/iidm/Switch.hpp>
#include <powsybl/iidm/VoltageLevelAdder.hpp>
#include <powsybl/network/EurostagFactory.hpp>

#include <powsybl/test/AssertionUtils.hpp>

Expand Down Expand Up @@ -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<std::reference_wrapper<const Bus>> buses;
voltage_level::BusBreakerView::Traverser traverser = [&buses, &sw1](const Bus& /*bus1*/, const stdcxx::Reference<Switch>& 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
Expand Down

0 comments on commit 180aa52

Please sign in to comment.