Skip to content
Snippets Groups Projects
Commit cd6d04fe authored by Octave Perrin's avatar Octave Perrin
Browse files

review

parent 37a75592
No related tags found
No related merge requests found
Pipeline #60966 failed
...@@ -882,29 +882,37 @@ TEST_CASE("[core/graph] AIDGE_TEST_0108000: Replacing a set of nodes, same input ...@@ -882,29 +882,37 @@ TEST_CASE("[core/graph] AIDGE_TEST_0108000: Replacing a set of nodes, same input
Log::setFileLevel(Log::Level::Warn); Log::setFileLevel(Log::Level::Warn);
std::vector<std::string> logs; std::vector<std::string> logs;
std::shared_ptr<GraphView> graphTest = std::make_shared<GraphView>("test_graph"); std::shared_ptr<GraphView> graphTest = std::make_shared<GraphView>("test_graph");
// Create old graph
auto otherInput = GenericOperator("Producer", {}, 1, "other_input"); auto otherInput = GenericOperator("Producer", {}, 1, "other_input");
auto other1 = GenericOperator("Other", {InputCategory::Data}, 1, "other1"); auto other1 = GenericOperator("Other", {InputCategory::Data}, 1, "other1");
auto myOld1 = GenericOperator("Old", {InputCategory::Data}, 1, "old1"); auto myOld1 = GenericOperator("Old", {InputCategory::Data}, 1, "old1");
auto myOld2 = GenericOperator("Old", {InputCategory::Data}, 1, "old2"); auto myOld2 = GenericOperator("Old", {InputCategory::Data}, 1, "old2");
auto other2 = GenericOperator("Other", {InputCategory::Data}, 1, "other2"); auto other2 = GenericOperator("Other", {InputCategory::Data}, 1, "other2");
// Link old graph
otherInput->addChild(other1); otherInput->addChild(other1);
other1->addChild(myOld1); other1->addChild(myOld1);
myOld1->addChild(myOld2); myOld1->addChild(myOld2);
myOld2->addChild(other2); myOld2->addChild(other2);
graphTest->add({other1, myOld1, myOld2, other2}); graphTest->add({other1, myOld1, myOld2, other2});
// Create and link new graph
auto myNew1 = GenericOperator("New", {InputCategory::Data}, 1, "new1"); auto myNew1 = GenericOperator("New", {InputCategory::Data}, 1, "new1");
auto myNew2 = GenericOperator("New", {InputCategory::Data}, 1, "new2"); auto myNew2 = GenericOperator("New", {InputCategory::Data}, 1, "new2");
myNew1->addChild(myNew2); myNew1->addChild(myNew2);
// Replace
bool retValue = GraphView::replace({myOld1, myOld2}, {myNew1, myNew2}); bool retValue = GraphView::replace({myOld1, myOld2}, {myNew1, myNew2});
// Check outputs
CHECK(LoadTextFile("my_log.txt", logs)); CHECK(LoadTextFile("my_log.txt", logs));
CHECK(logs.size() == 0); CHECK(logs.size() == 0);
CHECK(graphTest->getNodes() == std::set<std::shared_ptr<Node>>({other1, myNew1, myNew2, other2})); CHECK(graphTest->getNodes() == std::set<std::shared_ptr<Node>>({other1, myNew1, myNew2, other2}));
graphTest->save("myGraph",true,true); graphTest->save("myGraph",true,true);
CHECK(retValue); CHECK(retValue);
// Check links
CHECK(myNew1->input(0).first == other1); CHECK(myNew1->input(0).first == other1);
CHECK(myNew2->output(0).at(0).first == other2); CHECK(myNew2->output(0).at(0).first == other2);
// Check graph Nodes
CHECK(graphTest->getNode("old1") == nullptr); CHECK(graphTest->getNode("old1") == nullptr);
CHECK(graphTest->getNode("old2") == nullptr); CHECK(graphTest->getNode("old2") == nullptr);
CHECK(graphTest->getNode("new1") == myNew1); CHECK(graphTest->getNode("new1") == myNew1);
...@@ -916,6 +924,7 @@ TEST_CASE("[core/graph] AIDGE_TEST_0108000: Replacing a set of nodes, same input ...@@ -916,6 +924,7 @@ TEST_CASE("[core/graph] AIDGE_TEST_0108000: Replacing a set of nodes, same input
Log::setFileLevel(Log::Level::Warn); Log::setFileLevel(Log::Level::Warn);
std::vector<std::string> logs; std::vector<std::string> logs;
std::shared_ptr<GraphView> graphTest = std::make_shared<GraphView>("test_graph"); std::shared_ptr<GraphView> graphTest = std::make_shared<GraphView>("test_graph");
// Create old graph
auto otherInput1 = GenericOperator("Producer", {}, 1, "other_input1"); auto otherInput1 = GenericOperator("Producer", {}, 1, "other_input1");
auto otherInput2 = GenericOperator("Producer", {}, 1, "other_input2"); auto otherInput2 = GenericOperator("Producer", {}, 1, "other_input2");
auto other11 = GenericOperator("Other", {InputCategory::Data}, 1, "other11"); auto other11 = GenericOperator("Other", {InputCategory::Data}, 1, "other11");
...@@ -926,16 +935,18 @@ TEST_CASE("[core/graph] AIDGE_TEST_0108000: Replacing a set of nodes, same input ...@@ -926,16 +935,18 @@ TEST_CASE("[core/graph] AIDGE_TEST_0108000: Replacing a set of nodes, same input
auto myOld22 = GenericOperator("Old", {InputCategory::Data}, 1, "old22"); auto myOld22 = GenericOperator("Old", {InputCategory::Data}, 1, "old22");
auto other21 = GenericOperator("Other", {InputCategory::Data}, 1, "other21"); auto other21 = GenericOperator("Other", {InputCategory::Data}, 1, "other21");
auto other22 = GenericOperator("Other", {InputCategory::Data}, 1, "other22"); auto other22 = GenericOperator("Other", {InputCategory::Data}, 1, "other22");
// Link old graph
otherInput1->addChild(other11); otherInput1->addChild(other11);
other11->addChild(myOld11); other11->addChild(myOld11);
myOld11->addChild(myOld12); myOld11->addChild(myOld12);
myOld12->addChild(other12); myOld12->addChild(other12);
otherInput2->addChild(other11); otherInput2->addChild(other21);
other21->addChild(myOld21); other21->addChild(myOld21);
myOld21->addChild(myOld22); myOld21->addChild(myOld22);
myOld22->addChild(other22); myOld22->addChild(other22);
graphTest->add({other11, myOld11, myOld12, other12, other21, myOld21, myOld22, other22}); graphTest->add({other11, myOld11, myOld12, other12, other21, myOld21, myOld22, other22});
// Create and link new graph
auto myNew11 = GenericOperator("New", {InputCategory::Data}, 1, "new11"); auto myNew11 = GenericOperator("New", {InputCategory::Data}, 1, "new11");
auto myNew12 = GenericOperator("New", {InputCategory::Data}, 1, "new12"); auto myNew12 = GenericOperator("New", {InputCategory::Data}, 1, "new12");
auto myNew21 = GenericOperator("New", {InputCategory::Data}, 1, "new21"); auto myNew21 = GenericOperator("New", {InputCategory::Data}, 1, "new21");
...@@ -943,16 +954,21 @@ TEST_CASE("[core/graph] AIDGE_TEST_0108000: Replacing a set of nodes, same input ...@@ -943,16 +954,21 @@ TEST_CASE("[core/graph] AIDGE_TEST_0108000: Replacing a set of nodes, same input
myNew11->addChild(myNew12); myNew11->addChild(myNew12);
myNew21->addChild(myNew22); myNew21->addChild(myNew22);
// Replace
bool retValue = GraphView::replace({myOld11, myOld12, myOld21, myOld22}, {myNew11, myNew12, myNew21, myNew22}); bool retValue = GraphView::replace({myOld11, myOld12, myOld21, myOld22}, {myNew11, myNew12, myNew21, myNew22});
// Check outputs
CHECK(LoadTextFile("my_log.txt", logs)); CHECK(LoadTextFile("my_log.txt", logs));
CHECK(logs.size() == 0); CHECK(logs.size() == 0);
CHECK(graphTest->getNodes() == std::set<std::shared_ptr<Node>>({other11, myNew11, myNew12, other12, other21, myNew21, myNew22, other22})); CHECK(graphTest->getNodes() == std::set<std::shared_ptr<Node>>({other11, myNew11, myNew12, other12, other21, myNew21, myNew22, other22}));
graphTest->save("myGraph",true,true); graphTest->save("myGraph",true,true);
CHECK(retValue); CHECK(retValue);
// Check links
CHECK(myNew11->input(0).first == other11); CHECK(myNew11->input(0).first == other11);
CHECK(myNew12->output(0).at(0).first == other12); CHECK(myNew12->output(0).at(0).first == other12);
CHECK(myNew21->input(0).first == other21); CHECK(myNew21->input(0).first == other21);
CHECK(myNew22->output(0).at(0).first == other22); CHECK(myNew22->output(0).at(0).first == other22);
// Check graph Nodes
CHECK(graphTest->getNode("old11") == nullptr); CHECK(graphTest->getNode("old11") == nullptr);
CHECK(graphTest->getNode("old21") == nullptr); CHECK(graphTest->getNode("old21") == nullptr);
CHECK(graphTest->getNode("old21") == nullptr); CHECK(graphTest->getNode("old21") == nullptr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment