fix test cases running in stackoverlfow

This commit is contained in:
Frank Haverland
2022-10-27 20:14:26 +02:00
parent c4bbd7c545
commit f935c38571
4 changed files with 30 additions and 18 deletions

View File

@@ -4,7 +4,6 @@
#include <unity.h> #include <unity.h>
#include <ClassFlowPostProcessing.h> #include <ClassFlowPostProcessing.h>
#include <ClassFlowCNNGeneral.h> #include <ClassFlowCNNGeneral.h>
#include <ClassFlowCNNGeneral.h>
#include <ClassFlowMakeImage.h> #include <ClassFlowMakeImage.h>
#include <Helper.h> #include <Helper.h>

View File

@@ -8,6 +8,8 @@
* *
*/ */
void testNegative() { void testNegative() {
// Ohne decimal_shift // Ohne decimal_shift
std::vector<float> digits = { 1.2, 6.7}; std::vector<float> digits = { 1.2, 6.7};
std::vector<float> analogs = { 9.5, 8.4}; std::vector<float> analogs = { 9.5, 8.4};

View File

@@ -13,7 +13,7 @@
* expected - enthält das erwartete Ergebnis, wobei der Dezimalpunkt genau zwischen digits und analog ist. * expected - enthält das erwartete Ergebnis, wobei der Dezimalpunkt genau zwischen digits und analog ist.
* *
*/ */
void test_doFlow() { void test_doFlowPP() {
/* /*
* *
@@ -27,7 +27,7 @@ void test_doFlow() {
std::vector<float> digits = { 1.2, 6.7}; std::vector<float> digits = { 1.2, 6.7};
std::vector<float> analogs = { 9.5, 8.4}; std::vector<float> analogs = { 9.5, 8.4};
const char* expected = "16.98"; const char* expected = "16.98";
const char* expected_extended = "16.984"; //const char* expected_extended = "16.984";
std::string result = process_doFlow(analogs, digits); std::string result = process_doFlow(analogs, digits);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
@@ -151,13 +151,15 @@ void test_doFlow() {
expected = "377988.4"; expected = "377988.4";
result = process_doFlow(analogs, digits); result = process_doFlow(analogs, digits);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
}
void test_doFlowPP1() {
// Fehler bei V11.2.0 // Fehler bei V11.2.0
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1233149877 // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1233149877
digits = { 0.0, 0.0, 7.0, 8.9}; // 79.9999(6) als falsches Ergebnis std::vector<float> digits = { 0.0, 0.0, 7.0, 8.9}; // 79.9999(6) als falsches Ergebnis
analogs = { 0.1, 0.1, 0.1, 9.6}; std::vector<float> analogs = { 0.1, 0.1, 0.1, 9.6};
expected = "78.9999"; const char* expected = "78.9999";
result = process_doFlow(analogs, digits); std::string result = process_doFlow(analogs, digits);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
// Fehler bei V11.2.0 // Fehler bei V11.2.0
@@ -167,13 +169,15 @@ void test_doFlow() {
expected = "395.8632"; expected = "395.8632";
result = process_doFlow(analogs, digits); result = process_doFlow(analogs, digits);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
}
void test_doFlowPP2() {
// Fehler bei V11.2.0 // Fehler bei V11.2.0
// https://github.com/jomjol/AI-on-the-edge-device/discussions/950#discussion-4338615 // https://github.com/jomjol/AI-on-the-edge-device/discussions/950#discussion-4338615
digits = { 1.0, 9.0, 9.0}; // Übergang wurde um 1 erhöht (200, statt 199) std::vector<float> digits = { 1.0, 9.0, 9.0}; // Übergang wurde um 1 erhöht (200, statt 199)
analogs = { 7.1, 4.8, 8.3}; std::vector<float> analogs = { 7.1, 4.8, 8.3};
expected = "199.748"; const char* expected = "199.748";
result = process_doFlow(analogs, digits, Digital); std::string result = process_doFlow(analogs, digits, Digital);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
// Fehler bei Rolling (2002-09-09) // Fehler bei Rolling (2002-09-09)
@@ -181,7 +185,7 @@ void test_doFlow() {
digits = { 3.0, 2.0, 2.0, 8.0, 9.0, 4.0, 1.7, 9.8}; // falscher Wert 32290.420 digits = { 3.0, 2.0, 2.0, 8.0, 9.0, 4.0, 1.7, 9.8}; // falscher Wert 32290.420
analogs = { }; analogs = { };
expected = "32289.420"; expected = "32289.420";
expected_extended= "32289.4198"; const char* expected_extended= "32289.4198";
// FALSCH! wegen ungenügender Präzision von NUMBERS->Value // FALSCH! wegen ungenügender Präzision von NUMBERS->Value
// expected_extended= "32289.4198"; // expected_extended= "32289.4198";
@@ -330,16 +334,18 @@ void test_doFlow() {
// checkConsistency=false und extendResolution=true // checkConsistency=false und extendResolution=true
result = process_doFlow(analogs, digits, Digital100, false, true, 0); result = process_doFlow(analogs, digits, Digital100, false, true, 0);
TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
}
void test_doFlowPP3() {
// Fehler bei V12.0.1 // Fehler bei V12.0.1
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1265523710 // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1265523710
digits = { 2.0, 4.0, 6.8}; // 246.2045 als falsches Ergebnis std::vector<float> digits = { 2.0, 4.0, 6.8}; // 246.2045 als falsches Ergebnis
analogs = { 2.2, 0.1, 4.5}; std::vector<float> analogs = { 2.2, 0.1, 4.5};
expected = "247.204"; const char* expected = "247.204";
expected_extended= "247.2045"; const char* expected_extended= "247.2045";
// extendResolution=false // extendResolution=false
result = process_doFlow(analogs, digits, Digital100, false, false, 0); std::string result = process_doFlow(analogs, digits, Digital100, false, false, 0);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
// checkConsistency=false und extendResolution=true // checkConsistency=false und extendResolution=true

View File

@@ -104,13 +104,18 @@ extern "C" void app_main()
{ {
initGPIO(); initGPIO();
Init_NVS_SDCard(); Init_NVS_SDCard();
esp_log_level_set("*", ESP_LOG_DEBUG); // set all components to ERROR level
UNITY_BEGIN(); UNITY_BEGIN();
RUN_TEST(testNegative); RUN_TEST(testNegative);
RUN_TEST(test_analogToDigit_Standard); RUN_TEST(test_analogToDigit_Standard);
RUN_TEST(test_analogToDigit_Transition); RUN_TEST(test_analogToDigit_Transition);
RUN_TEST(test_doFlow); RUN_TEST(test_doFlowPP);
RUN_TEST(test_doFlowPP1);
RUN_TEST(test_doFlowPP2);
RUN_TEST(test_doFlowPP3);
UNITY_END(); UNITY_END();
} }