Skip to content

Commit

Permalink
[IIDM V1.2] Add getNameOrId() and getOptionalName() into Identifiable (
Browse files Browse the repository at this point in the history
…#124) (#142)

Signed-off-by: Sébastien LAIGRE <slaigre@silicom.fr>
Signed-off-by: Mathieu BAGUE <mathieu.bague@rte-france.com>
  • Loading branch information
sebalaig authored Jul 21, 2020
1 parent db06239 commit 92fdb79
Show file tree
Hide file tree
Showing 24 changed files with 68 additions and 76 deletions.
4 changes: 3 additions & 1 deletion include/powsybl/iidm/Identifiable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ class Identifiable : public virtual Validable, public Extendable {

const std::string& getId() const;

const std::string& getName() const;
const std::string& getNameOrId() const;

virtual const Network& getNetwork() const = 0;

virtual Network& getNetwork() = 0;

const std::string& getOptionalName() const;

bool hasProperty() const;

bool hasProperty(const std::string& key) const;
Expand Down
2 changes: 1 addition & 1 deletion src/iidm/BusBreakerVoltageLevelTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CalculatedBusTopology::CalculatedBusTopology(BusBreakerVoltageLevel& voltageLeve

std::unique_ptr<MergedBus> CalculatedBusTopology::createMergedBus(unsigned long busCount, const MergedBus::BusSet& busSet) const {
const std::string& mergedBusId = stdcxx::format("%1%_%2%", m_voltageLevel.getId(), busCount);
const std::string& mergedBusName = m_voltageLevel.getName().empty() ? "" : stdcxx::format("%1%_%2%", m_voltageLevel.getName(), busCount);
const std::string& mergedBusName = m_voltageLevel.getOptionalName().empty() ? "" : stdcxx::format("%1%_%2%", m_voltageLevel.getOptionalName(), busCount);

return stdcxx::make_unique<MergedBus>(mergedBusId, mergedBusName, busSet);
}
Expand Down
6 changes: 5 additions & 1 deletion src/iidm/Identifiable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ std::string Identifiable::getMessageHeader() const {
return getTypeDescription() + " '" + m_id + "': ";
}

const std::string& Identifiable::getName() const {
const std::string& Identifiable::getNameOrId() const {
return m_name.empty() ? m_id : m_name;
}

const std::string& Identifiable::getOptionalName() const {
return m_name;
}

const std::string& Identifiable::getProperty(const std::string& key) const {
return m_properties.get(key);
}
Expand Down
4 changes: 2 additions & 2 deletions src/iidm/NodeBreakerVoltageLevelBusNamingStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ std::string BusNamingStrategy::getId(const std::vector<unsigned long>& nodes) {
}

std::string BusNamingStrategy::getName(const std::vector<unsigned long>& nodes) {
if (!m_voltageLevel.getName().empty()) {
if (!m_voltageLevel.getOptionalName().empty()) {
const auto& iter = std::min_element(nodes.cbegin(), nodes.cend());
return stdcxx::format("%1%_%2%", m_voltageLevel.getName(), *iter);
return stdcxx::format("%1%_%2%", m_voltageLevel.getOptionalName(), *iter);
}

return "";
Expand Down
5 changes: 3 additions & 2 deletions src/iidm/converter/xml/AbstractIdentifiableXml.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ void AbstractIdentifiableXml<Added, Adder, Parent>::write(const Added& identifia
context.getWriter().writeStartElement(context.getVersion().getPrefix(), getRootElementName());

context.getWriter().writeAttribute(ID, context.getAnonymizer().anonymizeString(identifiable.getId()));
if (identifiable.getId() != identifiable.getName()) {
context.getWriter().writeAttribute(NAME, context.getAnonymizer().anonymizeString(identifiable.getName()));
const auto& name = identifiable.getOptionalName();
if (!name.empty()) {
context.getWriter().writeAttribute(NAME, context.getAnonymizer().anonymizeString(name));
}
writeRootElementAttributes(identifiable, parent, context);

Expand Down
2 changes: 1 addition & 1 deletion test/iidm/BatteryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(constructor) {
const Battery& battery = network.getBattery("BAT1");

BOOST_CHECK_EQUAL("BAT1", battery.getId());
BOOST_CHECK_EQUAL("BAT1_NAME", battery.getName());
BOOST_CHECK_EQUAL("BAT1_NAME", battery.getOptionalName());
BOOST_CHECK_EQUAL(ConnectableType::BATTERY, battery.getType());
std::ostringstream oss;
oss << battery.getType();
Expand Down
10 changes: 5 additions & 5 deletions test/iidm/BusBreakerVoltageLevelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(BusTest) {
const auto& cBus = bus;

BOOST_CHECK_EQUAL("BUS", bus.getId());
BOOST_CHECK_EQUAL("BUS_NAME", bus.getName());
BOOST_CHECK_EQUAL("BUS_NAME", bus.getOptionalName());
BOOST_TEST(stdcxx::areSame(voltageLevel, bus.getVoltageLevel()));
BOOST_TEST(stdcxx::areSame(voltageLevel, cBus.getVoltageLevel()));
BOOST_CHECK_EQUAL(0UL, bus.getConnectedTerminalCount());
Expand Down Expand Up @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(SwitchTest) {
swAdder.setBus2("BUS2");
Switch& aSwitch = swAdder.add();
BOOST_CHECK_EQUAL("SW", aSwitch.getId());
BOOST_CHECK_EQUAL("SW_NAME", aSwitch.getName());
BOOST_CHECK_EQUAL("SW_NAME", aSwitch.getOptionalName());
BOOST_TEST(stdcxx::areSame(voltageLevel, aSwitch.getVoltageLevel()));
BOOST_TEST(!aSwitch.isFictitious());
BOOST_TEST(!aSwitch.isOpen());
Expand Down Expand Up @@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(CalculatedBusTopologyTest) {
stdcxx::Reference<Bus> mergedBus2 = vl.getBusView().getMergedBus("BUS2");
BOOST_TEST(stdcxx::areSame(mergedBus1.get(), mergedBus2.get()));
BOOST_CHECK_EQUAL("VL_0", mergedBus1.get().getId());
BOOST_CHECK_EQUAL("VL_0", mergedBus1.get().getName());
BOOST_CHECK(mergedBus1.get().getOptionalName().empty());

sw.setOpen(true);
VoltageLevel& vlTest = vl;
Expand Down Expand Up @@ -469,7 +469,7 @@ BOOST_AUTO_TEST_CASE(TerminalTest) {
busBreakerView.setConnectableBus("BUS1");
const auto& configuredBus = busBreakerView.getBus().get();
BOOST_CHECK_EQUAL("BUS1", configuredBus.getId());
BOOST_CHECK_EQUAL("BUS1_NAME", configuredBus.getName());
BOOST_CHECK_EQUAL("BUS1_NAME", configuredBus.getOptionalName());
const auto& cConfiguredBus = cBusBreakerView.getBus().get();
BOOST_TEST(stdcxx::areSame(configuredBus, cConfiguredBus));

Expand All @@ -479,7 +479,7 @@ BOOST_AUTO_TEST_CASE(TerminalTest) {
POWSYBL_ASSERT_REF_TRUE(cTerminal.getBusView().getBus());
const auto& mergedBus = terminal.getBusView().getBus().get();
BOOST_CHECK_EQUAL("VL_0", mergedBus.getId());
BOOST_CHECK_EQUAL("VL_0", mergedBus.getName());
BOOST_CHECK(mergedBus.getOptionalName().empty());

POWSYBL_ASSERT_THROW(terminal.getNodeBreakerView(), AssertionError, "Not implemented");
POWSYBL_ASSERT_THROW(cTerminal.getNodeBreakerView(), AssertionError, "Not implemented");
Expand Down
8 changes: 1 addition & 7 deletions test/iidm/DanglingLineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(constructor) {

const DanglingLine& danglingLine = network.getDanglingLine("DL1");
BOOST_CHECK_EQUAL("DL1", danglingLine.getId());
BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName());
BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getOptionalName());
BOOST_CHECK_EQUAL(ConnectableType::DANGLING_LINE, danglingLine.getType());
std::ostringstream oss;
oss << danglingLine.getType();
Expand Down Expand Up @@ -160,7 +160,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {

network.getVariantManager().setWorkingVariant("s1");
BOOST_CHECK_EQUAL("DL1", danglingLine.getId());
BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName());
BOOST_CHECK_CLOSE(1.0, danglingLine.getB(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(2.0, danglingLine.getG(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(3.0, danglingLine.getP0(), std::numeric_limits<double>::epsilon());
Expand All @@ -171,7 +170,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {
danglingLine.setB(100.0).setG(200.0).setP0(300.0).setQ0(400).setR(500.0).setX(600.0);

BOOST_CHECK_EQUAL("DL1", danglingLine.getId());
BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName());
BOOST_CHECK_CLOSE(100.0, danglingLine.getB(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(200.0, danglingLine.getG(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(300.0, danglingLine.getP0(), std::numeric_limits<double>::epsilon());
Expand All @@ -182,7 +180,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {

network.getVariantManager().setWorkingVariant("s2");
BOOST_CHECK_EQUAL("DL1", danglingLine.getId());
BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName());
BOOST_CHECK_CLOSE(100.0, danglingLine.getB(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(200.0, danglingLine.getG(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(3.0, danglingLine.getP0(), std::numeric_limits<double>::epsilon());
Expand All @@ -192,7 +189,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {
danglingLine.setB(150.0).setG(250.0).setP0(350.0).setQ0(450).setR(550.0).setX(650.0);

BOOST_CHECK_EQUAL("DL1", danglingLine.getId());
BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName());
BOOST_CHECK_CLOSE(150.0, danglingLine.getB(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(250.0, danglingLine.getG(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(350.0, danglingLine.getP0(), std::numeric_limits<double>::epsilon());
Expand All @@ -202,7 +198,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {

network.getVariantManager().setWorkingVariant(VariantManager::getInitialVariantId());
BOOST_CHECK_EQUAL("DL1", danglingLine.getId());
BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName());
BOOST_CHECK_CLOSE(150.0, danglingLine.getB(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(250.0, danglingLine.getG(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(3.0, danglingLine.getP0(), std::numeric_limits<double>::epsilon());
Expand All @@ -216,7 +211,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {
network.getVariantManager().cloneVariant("s2", "s3");
network.getVariantManager().setWorkingVariant("s3");
BOOST_CHECK_EQUAL("DL1", danglingLine.getId());
BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName());
BOOST_CHECK_CLOSE(150.0, danglingLine.getB(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(250.0, danglingLine.getG(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(350.0, danglingLine.getP0(), std::numeric_limits<double>::epsilon());
Expand Down
3 changes: 1 addition & 2 deletions test/iidm/GeneratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(integrity) {

Generator& gen = network.getGenerator("GEN1");
BOOST_CHECK_EQUAL("GEN1", gen.getId());
BOOST_CHECK_EQUAL("GEN1_NAME", gen.getName());
BOOST_CHECK_EQUAL("GEN1_NAME", gen.getOptionalName());
BOOST_CHECK_EQUAL(ConnectableType::GENERATOR, gen.getType());
std::ostringstream oss;
oss << gen.getType();
Expand Down Expand Up @@ -298,7 +298,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {

network.getVariantManager().setWorkingVariant("s1");
BOOST_CHECK_EQUAL("GEN1", gen.getId());
BOOST_CHECK_EQUAL("GEN1_NAME", gen.getName());
BOOST_CHECK_CLOSE(45, gen.getActivePowerSetpoint(), std::numeric_limits<double>::epsilon());
POWSYBL_ASSERT_ENUM_EQ(EnergySource::WIND, gen.getEnergySource());
BOOST_CHECK_CLOSE(50.0, gen.getMaxP(), std::numeric_limits<double>::epsilon());
Expand Down
9 changes: 2 additions & 7 deletions test/iidm/HvdcLineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE(constructor) {

const HvdcLine& hvdc = network.getHvdcLine("HVDC1");
BOOST_CHECK_EQUAL("HVDC1", hvdc.getId());
BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName());
BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getOptionalName());
BOOST_CHECK_CLOSE(11.0, hvdc.getActivePowerSetpoint(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_RECTIFIER_SIDE_2_INVERTER, hvdc.getConvertersMode());
BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId());
Expand Down Expand Up @@ -246,7 +246,7 @@ BOOST_AUTO_TEST_CASE(multivariant) {

network.getVariantManager().setWorkingVariant("s1");
BOOST_CHECK_EQUAL("HVDC1", hvdc.getId());
BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName());
BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getOptionalName());
BOOST_CHECK_CLOSE(11.0, hvdc.getActivePowerSetpoint(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_RECTIFIER_SIDE_2_INVERTER, hvdc.getConvertersMode());
BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId());
Expand All @@ -257,7 +257,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {
hvdc.setActivePowerSetpoint(100.0).setR(200.0).setMaxP(300.0).setConvertersMode(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER).setNominalVoltage(400.0);

BOOST_CHECK_EQUAL("HVDC1", hvdc.getId());
BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName());
BOOST_CHECK_CLOSE(100.0, hvdc.getActivePowerSetpoint(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER, hvdc.getConvertersMode());
BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId());
Expand All @@ -268,7 +267,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {

network.getVariantManager().setWorkingVariant("s2");
BOOST_CHECK_EQUAL("HVDC1", hvdc.getId());
BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName());
BOOST_CHECK_CLOSE(11.0, hvdc.getActivePowerSetpoint(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_RECTIFIER_SIDE_2_INVERTER, hvdc.getConvertersMode());
BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId());
Expand All @@ -279,7 +277,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {
hvdc.setActivePowerSetpoint(150.0).setR(250.0).setMaxP(350.0).setConvertersMode(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER).setNominalVoltage(450.0);

BOOST_CHECK_EQUAL("HVDC1", hvdc.getId());
BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName());
BOOST_CHECK_CLOSE(150.0, hvdc.getActivePowerSetpoint(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER, hvdc.getConvertersMode());
BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId());
Expand All @@ -290,7 +287,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {

network.getVariantManager().setWorkingVariant(VariantManager::getInitialVariantId());
BOOST_CHECK_EQUAL("HVDC1", hvdc.getId());
BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName());
BOOST_CHECK_CLOSE(11.0, hvdc.getActivePowerSetpoint(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_RECTIFIER_SIDE_2_INVERTER, hvdc.getConvertersMode());
BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId());
Expand All @@ -305,7 +301,6 @@ BOOST_AUTO_TEST_CASE(multivariant) {
network.getVariantManager().cloneVariant("s2", "s3");
network.getVariantManager().setWorkingVariant("s3");
BOOST_CHECK_EQUAL("HVDC1", hvdc.getId());
BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName());
BOOST_CHECK_CLOSE(150.0, hvdc.getActivePowerSetpoint(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER, hvdc.getConvertersMode());
BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId());
Expand Down
3 changes: 1 addition & 2 deletions test/iidm/LccConverterStationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ BOOST_AUTO_TEST_CASE(constructor) {
BOOST_TEST(stdcxx::areSame(lcc, hvdc));
BOOST_CHECK_EQUAL("LCC1", lcc.getId());
BOOST_CHECK_EQUAL(lcc.getId(), hvdc.getId());
BOOST_CHECK_EQUAL("LCC1_NAME", lcc.getName());
BOOST_CHECK_EQUAL(lcc.getName(), hvdc.getName());
BOOST_CHECK_EQUAL("LCC1_NAME", lcc.getOptionalName());
BOOST_CHECK_EQUAL(ConnectableType::HVDC_CONVERTER_STATION, lcc.getType());
std::ostringstream oss;
oss << lcc.getType();
Expand Down
3 changes: 2 additions & 1 deletion test/iidm/LineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ BOOST_AUTO_TEST_CASE(constructor) {

const Line& line = network.getLine("VL1_VL3");
BOOST_CHECK_EQUAL("VL1_VL3", line.getId());
BOOST_CHECK_EQUAL("VL1_VL3", line.getName());
BOOST_CHECK(line.getOptionalName().empty());
BOOST_CHECK_EQUAL("VL1_VL3", line.getNameOrId());
BOOST_CHECK_EQUAL(ConnectableType::LINE, line.getType());
std::ostringstream oss;
oss << line.getType();
Expand Down
2 changes: 1 addition & 1 deletion test/iidm/LoadTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE(constructor) {

Load& load = network.getLoad("LOAD1");
BOOST_CHECK_EQUAL("LOAD1", load.getId());
BOOST_CHECK_EQUAL("LOAD1_NAME", load.getName());
BOOST_CHECK_EQUAL("LOAD1_NAME", load.getOptionalName());
BOOST_CHECK_EQUAL(ConnectableType::LOAD, load.getType());
std::ostringstream oss;
oss << load.getType();
Expand Down
2 changes: 1 addition & 1 deletion test/iidm/NetworkTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ BOOST_AUTO_TEST_CASE(constructor) {

Network network("id", "sourceFormat");
BOOST_CHECK_EQUAL("id", network.getId());
BOOST_CHECK_EQUAL("id", network.getName());
BOOST_CHECK_EQUAL("id", network.getOptionalName());
BOOST_CHECK_EQUAL("sourceFormat", network.getSourceFormat());
BOOST_CHECK_EQUAL(0, network.getForecastDistance());

Expand Down
15 changes: 9 additions & 6 deletions test/iidm/NodeBreakerVoltageLevelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(busbarSection) {
.add();

BOOST_CHECK_EQUAL("BBS", bbs.getId());
BOOST_CHECK_EQUAL("BBS_NAME", bbs.getName());
BOOST_CHECK_EQUAL("BBS_NAME", bbs.getOptionalName());
BOOST_CHECK_EQUAL(ConnectableType::BUSBAR_SECTION, bbs.getType());
std::ostringstream oss;
oss << bbs.getType();
Expand Down Expand Up @@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(switches) {
.add();

BOOST_CHECK_EQUAL("BK", breaker.getId());
BOOST_CHECK_EQUAL("BK_NAME", breaker.getName());
BOOST_CHECK_EQUAL("BK_NAME", breaker.getOptionalName());
POWSYBL_ASSERT_ENUM_EQ(SwitchKind::BREAKER, breaker.getKind());
BOOST_TEST(!breaker.isOpen());
BOOST_TEST(breaker.isRetained());
Expand Down Expand Up @@ -531,7 +531,8 @@ BOOST_AUTO_TEST_CASE(calculatedBusBreakerTopology) {
auto& testBus = busBreakerView.getBus("VL_0").get();
const auto& cTestBus = testBus;
BOOST_CHECK_EQUAL("VL_0", testBus.getId());
BOOST_CHECK_EQUAL("VL_0", testBus.getName());
BOOST_CHECK(testBus.getOptionalName().empty());
BOOST_CHECK_EQUAL("VL_0", testBus.getNameOrId());
BOOST_CHECK_CLOSE(7.7, testBus.setAngle(7.7).setV(8.8).getAngle(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_CLOSE(8.8, testBus.getV(), std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(2UL, testBus.getConnectedTerminalCount());
Expand Down Expand Up @@ -685,7 +686,7 @@ BOOST_AUTO_TEST_CASE(CalculatedBusTopology) {
POWSYBL_ASSERT_REF_TRUE(cBusView.getMergedBus("BBS"));
const auto& calculatedBus = busView.getBus("VL_0").get();
BOOST_CHECK_EQUAL("VL_0", calculatedBus.getId());
BOOST_CHECK_EQUAL("VL_0", calculatedBus.getName());
BOOST_CHECK(calculatedBus.getOptionalName().empty());

sw.setOpen(true);
BOOST_CHECK_EQUAL(2UL, boost::size(busView.getBuses()));
Expand Down Expand Up @@ -986,7 +987,8 @@ BOOST_AUTO_TEST_CASE(TerminalTest) {
BOOST_TEST(stdcxx::areSame(cBusBreakerView.getBus().get(), cBusBreakerView.getConnectableBus().get()));
const auto& calculatedBus = busBreakerView.getBus().get();
BOOST_CHECK_EQUAL("VL_0", calculatedBus.getId());
BOOST_CHECK_EQUAL("VL_name_0", calculatedBus.getName());
BOOST_CHECK_EQUAL("VL_name_0", calculatedBus.getOptionalName());
BOOST_CHECK_EQUAL("VL_name_0", calculatedBus.getNameOrId());


POWSYBL_ASSERT_THROW(busBreakerView.setConnectableBus("BUS1"), AssertionError, "Not implemented");
Expand All @@ -998,7 +1000,8 @@ BOOST_AUTO_TEST_CASE(TerminalTest) {
BOOST_TEST(stdcxx::areSame(cBusView.getBus().get(), cBusView.getConnectableBus().get()));
const auto& calculatedBus2 = busView.getBus().get();
BOOST_CHECK_EQUAL("VL_0", calculatedBus2.getId());
BOOST_CHECK_EQUAL("VL_name_0", calculatedBus2.getName());
BOOST_CHECK_EQUAL("VL_name_0", calculatedBus2.getOptionalName());
BOOST_CHECK_EQUAL("VL_name_0", calculatedBus.getNameOrId());

BOOST_TEST(stdcxx::areSame(terminal.getNodeBreakerView(), cTerminal.getNodeBreakerView()));
BOOST_CHECK_EQUAL(2UL, terminal.getNodeBreakerView().getNode());
Expand Down
Loading

0 comments on commit 92fdb79

Please sign in to comment.