#include #include #include "Connector.h" using namespace mdd; /* TEST(Connector, encode) { //decode (3+4)*2 std::vector inputs; std::shared_ptr f1 = GetGenerators()["mdd::ModuleMath"]->Generate(); inputs = f1->getInputIDs(); f1->getInput(inputs[0])->setValue() = { 3 }; f1->getInput(inputs[1])->setValue() = { 4 }; std::shared_ptr f2 = GetGenerators()["mdd::ModuleMath"]->Generate(); f2->GetSubProp("operation")->Set("multiply"); //= std::make_shared(MathOperation::ADD); inputs = f2->getInputIDs(); f2->getInput(inputs[0])->connect(f1->getOutput(f1->getOutputIDs()[0])); f2->getInput(inputs[1])->setValue() = { 2 }; std::shared_ptr processor = std::make_shared(); processor->addModule(f1); processor->addModule(f2); processor->addModuleOutput(f2, f2->getOutput(f2->getOutputIDs()[0])); processor->update(); EXPECT_EQ((int)f1->getOutput(f1->getOutputIDs()[0])->getValue()[0], 7); EXPECT_EQ((int)f2->getOutput(f2->getOutputIDs()[0])->getValue()[0], 14); EXPECT_EQ((int)processor->getOutput(processor->getOutputIDs()[1])->getValue()[0], 14); json code = Connector::encode(processor); code = "test"; std::cout << code.dump() << std::endl; json m1; m1["type"] = "Math"; m1["params"] = { "param1", "param2","..." }; json m2; m2["type"] = "Math"; m2["params"] = { "param1", "param2","..." }; json p; p["type"] = "StandardProcessor"; p["subs"] = { m1, m2 }; p["connections"] = { {"in1", "out1"}, {"in2", "out2"} }; EXPECT_EQ(code.dump(), p.dump()); } TEST(Connector, decode) { //parse (3+4)*2 json m1; m1["type"] = "Math"; m1["params"] = { "param1", "param2","..." }; json m2; m2["type"] = "Math"; m2["params"] = { "param1", "param2","..." }; json p; p["type"] = "StandardProcessor"; p["subs"] = {m1, m2}; p["connections"] = { {"in1", "out1"}, {"in2", "out2"} }; auto module = Connector::decode(p); //auto ids_out = module->getOutputIDs(); //EXPECT_EQ((int)module->getOutput(ids_out[0])->getValue()[0], 14); }*/