test_flowpostprocessing.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #include <unity.h>
  2. #include <ClassFlowPostProcessing.h>
  3. #include <ClassFlowCNNGeneral.h>
  4. #include <ClassFlowCNNGeneral.h>
  5. #include <ClassFlowMakeImage.h>
  6. ClassFlowCNNGeneral* _analog;
  7. ClassFlowCNNGeneral* _digit;
  8. std::vector<ClassFlow*> FlowControll;
  9. ClassFlowMakeImage* flowmakeimage;
  10. class UnderTestPost : public ClassFlowPostProcessing {
  11. public:
  12. UnderTestPost(std::vector<ClassFlow*>* lfc, ClassFlowCNNGeneral *_analog, ClassFlowCNNGeneral *_digit)
  13. : ClassFlowPostProcessing::ClassFlowPostProcessing(lfc, _analog, _digit) {}
  14. using ClassFlowPostProcessing::InitNUMBERS;
  15. };
  16. UnderTestPost* undertestPost;
  17. void setUpClassFlowPostprocessing(void)
  18. {
  19. // wird im doFlow verwendet
  20. flowmakeimage = new ClassFlowMakeImage(&FlowControll);
  21. FlowControll.push_back(flowmakeimage);
  22. // Die Modeltypen werden gesetzt, da keine Modelle verwendet werden.
  23. _analog = new ClassFlowCNNGeneral(nullptr, Analogue100);
  24. _digit = new ClassFlowCNNGeneral(nullptr, Digital100);
  25. undertestPost = new UnderTestPost(&FlowControll, _analog, _digit);
  26. }
  27. /**
  28. * @brief getestet wird das Ergebnis von
  29. * digit1 = 1.2
  30. * digit2 = 6.7
  31. * analog1 = 9.5
  32. * analog2 = 8.4
  33. *
  34. * Das Ergebnis sollte "16.984" sein.
  35. */
  36. void test_doFlow() {
  37. // setup the classundertest
  38. setUpClassFlowPostprocessing();
  39. printf("SetupClassFlowPostprocessing completed.\n");
  40. general* gen_digit = _digit->GetGENERAL("default", true);
  41. // digit1
  42. roi* digit1 = new roi();
  43. digit1->name = "digit1";
  44. digit1->result_float = 1.2;
  45. gen_digit->ROI.push_back(digit1);
  46. // digit2
  47. roi* digit2 = new roi();
  48. digit2->name = "digit2";
  49. digit2->result_float = 6.7;
  50. gen_digit->ROI.push_back(digit2);
  51. general* gen_analog = _analog->GetGENERAL("default", true);
  52. // analog1
  53. roi* analog1 = new roi();
  54. analog1->name = "analog1";
  55. analog1->result_float = 9.5;
  56. gen_analog->ROI.push_back(analog1);
  57. // analog2
  58. roi* analog2 = new roi();
  59. analog2->name = "analog2";
  60. analog2->result_float = 8.4;
  61. gen_analog->ROI.push_back(analog2);
  62. printf("Setup ROIs completed.\n");
  63. undertestPost->InitNUMBERS();
  64. string time;
  65. // run test
  66. TEST_ASSERT_TRUE(undertestPost->doFlow(time));
  67. printf("DoFlow completed.\n");
  68. TEST_ASSERT_EQUAL_STRING("0000", undertestPost->getReadout(0).c_str());
  69. }