test_ModuleSwitch.cpp 2.2 KB

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