Fix negatives on extended resolution false #2744 (#2772)

* not extended resolution allows -1 on the lowest digit

* not extended resolution allows -1 on the lowest number

* negatives on last value digit with -1 will set to prevalue and is not an error  #2744

---------

Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com>
This commit is contained in:
Frank Haverland
2023-12-31 12:03:52 +01:00
committed by GitHub
parent a11e19fb0c
commit 6fca4d8d95
3 changed files with 50 additions and 22 deletions

View File

@@ -51,21 +51,32 @@ void testNegative() {
delete underTestPost;
// extendResolution=false
// value < preValue
preValue = 16.99; // zu groß
// value < (preValue -.01)
preValue = 17.00; // zu groß
underTestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
setAllowNegatives(underTestPost, false);
setPreValue(underTestPost, preValue_extended);
setPreValue(underTestPost, preValue);
result = process_doFlow(underTestPost);
TEST_ASSERT_EQUAL_STRING("Neg. Rate - Read: - Raw: 16.98 - Pre: 16.99 ", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING("Neg. Rate - Read: - Raw: 16.98 - Pre: 17.00 ", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING("", result.c_str());
delete underTestPost;
// extendResolution=false
// value > (preValue -.01)
// ist im Rahmen der Ungenauigkeit (-1 auf letzter Stelle)
preValue = 16.99; // zu groß
underTestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
setAllowNegatives(underTestPost, false);
setPreValue(underTestPost, preValue);
result = process_doFlow(underTestPost);
TEST_ASSERT_EQUAL_STRING("no error", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING("16.99", result.c_str());
delete underTestPost;
// extendResolution=false
// value < preValue
// Aber Prüfung abgeschaltet => kein Fehler
preValue = 16.99; // zu groß
preValue = 17.99; // zu groß
underTestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
setAllowNegatives(underTestPost, true);
setPreValue(underTestPost, preValue_extended);
@@ -84,8 +95,8 @@ void testNegative_Issues() {
// Ohne decimal_shift
std::vector<float> digits = { 2.0, 2.0, 0.0, 1.0, 7.2, 9.0, 8.0};
std::vector<float> analogs = { };
double preValue_extended = 22018.080;
double preValue = 22018.08;
double preValue_extended = 22018.090;
double preValue = 22018.09;
const char* expected = "22017.98";
@@ -93,13 +104,13 @@ void testNegative_Issues() {
// extendResolution=false
// value < preValue
// Prüfung eingeschaltet => Fehler
preValue = 22018.08; // zu groß
preValue = 22018.09; // zu groß
UnderTestPost* underTestPost = init_do_flow(analogs, digits, Digital100, false, false, -2);
setAllowNegatives(underTestPost, false);
setPreValue(underTestPost, preValue_extended);
std::string result = process_doFlow(underTestPost);
TEST_ASSERT_EQUAL_STRING("Neg. Rate - Read: - Raw: 22017.98 - Pre: 22018.08 ", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
TEST_ASSERT_EQUAL_STRING("Neg. Rate - Read: - Raw: 22017.98 - Pre: 22018.09 ", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING("", result.c_str());
delete underTestPost;
}