test_ModuleSwitch.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <gtest/gtest.h>
  2. #include <json.hpp>
  3. //#define private public
  4. #include <Registration.h>
  5. using namespace mdd;
  6. /*
  7. TEST(ModuleSwitch, EasySwitch){
  8. ModuleSwitch sModule = ModuleSwitch();
  9. auto inputs = sModule.getInputIDs();
  10. auto outputs = sModule.getOutputIDs();
  11. sModule.getInput(inputs[0])->setValue() = { 0 };
  12. sModule.getInput(inputs[1])->setValue() = { 1 };
  13. sModule.getInput(inputs[2])->setValue() = { 2 };
  14. sModule.update();
  15. EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 1);
  16. sModule.getInput(inputs[0])->setValue() = { 1 };
  17. sModule.update();
  18. EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 1);
  19. sModule.getInput(inputs[0])->setValue() = { 2 };
  20. sModule.update();
  21. EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 2);
  22. sModule.getInput(inputs[0])->setValue() = { 3 };
  23. sModule.update();
  24. EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 2);
  25. sModule.getInput(inputs[0])->setValue() = { 33 };
  26. sModule.update();
  27. EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 2);
  28. }
  29. TEST(ModuleSwitch, ConnectTest){
  30. ModuleMath f0 = ModuleMath(MathOperation::MULTIPLY);
  31. auto inputs = f0.getInputIDs();
  32. f0.getInput(inputs[0])->setValue() = { 1 };
  33. f0.getInput(inputs[1])->setValue() = { 1 };
  34. ModuleMath f1 = ModuleMath(MathOperation::MULTIPLY);
  35. inputs = f1.getInputIDs();
  36. f1.getInput(inputs[0])->setValue() = { 2 };
  37. f1.getInput(inputs[1])->setValue() = { 3 };
  38. ModuleMath f2 = ModuleMath(MathOperation::MULTIPLY);
  39. inputs = f2.getInputIDs();
  40. f2.getInput(inputs[0])->setValue() = { 5 };
  41. f2.getInput(inputs[1])->setValue() = { 7 };
  42. ModuleSwitch sModule = ModuleSwitch();
  43. inputs = sModule.getInputIDs();
  44. sModule.getInput(inputs[0])->connect(f0.getOutput(f0.getOutputIDs()[0]));
  45. sModule.getInput(inputs[1])->connect(f1.getOutput(f1.getOutputIDs()[0]));
  46. sModule.getInput(inputs[2])->connect(f2.getOutput(f2.getOutputIDs()[0]));
  47. f0.update();
  48. f1.update();
  49. f2.update();
  50. sModule.update();
  51. //std::cout << sModule.getOutput(sModule.getOutputIDs()[0])->getValue()["value"].dump() << std::endl;
  52. EXPECT_EQ(sModule.getOutput(sModule.getOutputIDs()[0])->getValue()[0], 6);
  53. }*/