#include #include //#define private public #include using namespace mdd; namespace TEST_MODULE_SWITCH { auto regi = Registration(); TEST(ModuleSwitch, EasySwitch){ IModule::Ptr sModule = regi.generateModule("ModuleSwitch"); json config = json::parse(sModule->getConfiguration()); config[0]["value"] = 2; sModule->configure(config.dump()); sModule->getInput(0)->setValue() = { 0 }; sModule->getInput(1)->setValue() = { 1 }; sModule->getInput(2)->setValue() = { 2 }; sModule->update(); EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 1); sModule->getInput(0)->setValue() = { 1 }; sModule->update(); EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 1); sModule->getInput(0)->setValue() = { 2 }; sModule->update(); EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 2); sModule->getInput(0)->setValue() = { 3 }; sModule->update(); EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 2); sModule->getInput(0)->setValue() = { 33 }; sModule->update(); EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 2); } TEST(ModuleSwitch, ConnectTest){ IModule::Ptr f0 = regi.generateModule("ModuleMath"); json config = json::parse(f0->getConfiguration()); config[0]["value"] = "multiply"; f0->configure(config.dump()); f0->getInput(0)->setValue() = { 1 }; f0->getInput(1)->setValue() = { 1 }; IModule::Ptr f1 = regi.generateModule("ModuleMath"); config = json::parse(f1->getConfiguration()); config[0]["value"] = "multiply"; f1->configure(config.dump()); f1->getInput(0)->setValue() = { 2 }; f1->getInput(1)->setValue() = { 3 }; IModule::Ptr f2 = regi.generateModule("ModuleMath"); config = json::parse(f2->getConfiguration()); config[0]["value"] = "multiply"; f2->configure(config.dump()); f2->getInput(0)->setValue() = { 5 }; f2->getInput(1)->setValue() = { 7 }; IModule::Ptr sModule = regi.generateModule("ModuleSwitch"); config = json::parse(sModule->getConfiguration()); config[0]["value"] = 2; sModule->configure(config.dump()); sModule->getInput(0)->connect(f0->getOutput(0)); sModule->getInput(1)->connect(f1->getOutput(0)); sModule->getInput(2)->connect(f2->getOutput(0)); f0->update(); f1->update(); f2->update(); sModule->update(); //std::cout << sModule.getOutput(sModule.getOutputIDs()[0])->getValue()["value"].dump() << std::endl; EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 6); }//*/ }