Addressing final comments and test failures.
This commit is contained in:
parent
f8a38064e1
commit
96b0b09b14
@ -151,13 +151,12 @@ std::optional<Branch> ExtNetwork::uptree_branch(const std::string& node) const {
|
||||
|
||||
|
||||
std::vector<Branch> ExtNetwork::downtree_branches(const std::string& node) const {
|
||||
std::vector<Branch> branches;
|
||||
|
||||
if (!this->has_node(node)) {
|
||||
auto msg = fmt::format("Requesting downtree branches of undefined node: {}", node);
|
||||
throw std::out_of_range(msg);
|
||||
}
|
||||
|
||||
std::vector<Branch> branches;
|
||||
std::copy_if(this->m_branches.begin(), this->m_branches.end(), std::back_inserter(branches), [&node](const Branch& b) { return b.uptree_node() == node; });
|
||||
return branches;
|
||||
}
|
||||
@ -197,7 +196,7 @@ void ExtNetwork::update_node(Node node)
|
||||
auto branch = std::find_if(this->m_branches.begin(), this->m_branches.end(),
|
||||
[&name](const Branch& b) { return b.uptree_node() == name || b.downtree_node() == name;});
|
||||
|
||||
if (branch->downtree_node() == name) {
|
||||
if (branch != this->m_branches.end() && branch->downtree_node() == name) {
|
||||
if (node.as_choke() && branch->vfp_table().has_value())
|
||||
throw std::invalid_argument("Node: " + name + " should serve as a choke => upstream branch can not have VFP table");
|
||||
}
|
||||
|
@ -96,7 +96,9 @@ NODEPROP
|
||||
/
|
||||
)";
|
||||
|
||||
BOOST_CHECK_THROW( make_schedule(deck_string), std::exception);
|
||||
const auto& schedule = make_schedule(deck_string);
|
||||
const auto& network = schedule[0].network.get();
|
||||
BOOST_CHECK(network.has_node("B1X"));
|
||||
}
|
||||
|
||||
|
||||
@ -130,7 +132,9 @@ NODEPROP
|
||||
/
|
||||
)";
|
||||
|
||||
BOOST_CHECK_THROW( make_schedule(deck_string), std::exception);
|
||||
const auto& schedule = make_schedule(deck_string);
|
||||
const auto& network = schedule[0].network.get();
|
||||
BOOST_CHECK(network.has_node("PLAT-AX"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(INVALID_VFP_NODE) {
|
||||
@ -264,9 +268,9 @@ BRANPROP
|
||||
BOOST_CHECK_EQUAL(B1_uptree->downtree_node(), "B1");
|
||||
BOOST_CHECK_EQUAL(B1_uptree->uptree_node(), "PLAT-A");
|
||||
|
||||
BOOST_CHECK_THROW( network.uptree_branch("C1"), std::out_of_range);
|
||||
BOOST_CHECK_THROW( network.node("C1"), std::out_of_range);
|
||||
|
||||
BOOST_CHECK( network.has_node("C1") );
|
||||
BOOST_CHECK( !network.uptree_branch("C1") );
|
||||
|
||||
BOOST_CHECK(network.active());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user