Forked from
Eclipse Projects / aidge / aidge_core
2432 commits behind the upstream repository.
-
vincent lorrain authoredvincent lorrain authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Test_FsmMatch.cpp 1.76 KiB
#include <catch2/catch_test_macros.hpp>
#include "aidge/graph/GraphView.hpp"
#include "aidge/operator/Conv.hpp"
#include "aidge/operator/GenericOperator.hpp"
#include "aidge/operator/Producer.hpp"
#include "aidge/graphRegex/GraphFsmInterpreter.hpp"
using namespace Aidge;
TEST_CASE("FsmMatch") {
SECTION("Construction") {
std::map<std::string,std::shared_ptr<ConditionalInterpreter>> allTest = {
{"A",std::make_shared<ConditionalInterpreter>("isConv($)==true")},
{"B",std::make_shared<ConditionalInterpreter>("isConv($)==true")},
{"C",std::make_shared<ConditionalInterpreter>("true==true")}
};
allTest["A"]->insertLambda("isConv",+[](NodePtr NodeOp){return NodeOp->type() == "Conv";});
allTest["B"]->insertLambda("isConv",+[](NodePtr NodeOp){return NodeOp->type() == "Conv";});
std::shared_ptr<GraphFsmInterpreter> fsmGenerator = std::make_shared<GraphFsmInterpreter>("A#->B",allTest);
std::shared_ptr<FsmGraph> fsm = fsmGenerator->interpret();
//REQUIRE(fsm->getNodes().size() == 3);
//REQUIRE(fsm->getStartNodes().size() == 1);
std::shared_ptr<GraphView> g1 = std::make_shared<GraphView>("TestGraph");
std::shared_ptr<Node> conv = GenericOperator("Conv", 1, 1, 1, "c");
std::shared_ptr<Node> conv1 = GenericOperator("Conv", 1, 1, 1, "c1");
g1->add(conv);
g1->addChild(conv1, "c");
REQUIRE(allTest["A"]->test(conv) == true);
REQUIRE(allTest["B"]->test(conv) == true);
std::vector<std::shared_ptr<Node>> startNodes = {conv};
auto result = fsm->test(startNodes);
REQUIRE( result->getBiggerSolution() == std::set<NodePtr>{conv,conv1});
}
SECTION("split"){
}
}