Przeglądaj źródła

fix testcase creation if analog has no pointers

Frank Haverland 3 lat temu
rodzic
commit
45d37ea957

+ 1 - 3
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp

@@ -866,8 +866,6 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
 
 void ClassFlowPostProcessing::WriteDataLog(int _index)
 {
-    LogFile.WriteToFile(ESP_LOG_WARN, "Data file writing temporarily disabled, see https://github.com/jomjol/AI-on-the-edge-device/issues/1225");
-    return;
     string analog = "";
     string digital = "";
     string timezw = "";
@@ -875,7 +873,7 @@ void ClassFlowPostProcessing::WriteDataLog(int _index)
     struct tm* timeinfo = localtime(&NUMBERS[_index]->lastvalue);
     strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
     timezw = std::string(buffer);
-
+    
     if (flowAnalog)
         analog = flowAnalog->getReadoutRawString(_index);
     if (flowDigit)

+ 2 - 0
code/test/components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp

@@ -82,6 +82,8 @@ UnderTestPost* init_do_flow(std::vector<float> analog, std::vector<float> digits
             anaROI->result_float = analog[i];
             gen_analog->ROI.push_back(anaROI);
         }
+    } else {
+        _undertestPost->flowAnalog = NULL;
     }
     ESP_LOGD(TAG, "Setting up of ROIs completed.");
 

+ 11 - 10
code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp

@@ -108,11 +108,14 @@ void test_doFlowPP() {
         result = process_doFlow(analogs, digits);
         TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
        
+}
+
+void test_doFlowPP1() {
         // https://github.com/jomjol/AI-on-the-edge-device/issues/942#issuecomment-1226966346
-        digits = { 0.0, 2.9, 3.0, 2.9, 3.5, 9.5};
-        analogs = {        };
-        expected = "33330";
-        result = process_doFlow(analogs, digits);
+        std::vector<float> digits = { 0.0, 2.9, 3.0, 2.9, 3.5, 9.5};
+        std::vector<float>  analogs = {        };
+        const char* expected = "33330";
+        std::string result = process_doFlow(analogs, digits);
         TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
 
         // https://github.com/jomjol/AI-on-the-edge-device/issues/942#issuecomment-1226966346
@@ -151,15 +154,13 @@ void test_doFlowPP() {
         expected = "377988.4";
         result = process_doFlow(analogs, digits);
         TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
-}
 
-void test_doFlowPP1() {
         // Fehler bei V11.2.0
         // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1233149877
-        std::vector<float> digits = { 0.0, 0.0, 7.0, 8.9};  // 79.9999(6) als falsches Ergebnis
-        std::vector<float> analogs = { 0.1, 0.1, 0.1, 9.6};
-        const char* expected = "78.9999";
-        std::string result = process_doFlow(analogs, digits);
+        digits = { 0.0, 0.0, 7.0, 8.9};  // 79.9999(6) als falsches Ergebnis
+        analogs = { 0.1, 0.1, 0.1, 9.6};
+        expected = "78.9999";
+        result = process_doFlow(analogs, digits);
         TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
 
         // Fehler bei V11.2.0