Fixed test issue with overflow of times #574

Merged
mohr merged 3 commits from gaisser/fsfw:gaisser_ccsds_time_tests into development 2022-03-14 14:23:36 +01:00
Showing only changes of commit 445d5dd6f0 - Show all commits

View File

@ -111,12 +111,20 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") {
CCSDSTime::CDS_short cdsTime;
result = CCSDSTime::convertToCcsds(&cdsTime, &timeAsTimeval);
CHECK(result == HasReturnvaluesIF::RETURN_OK);
// Days in CCSDS Epoch 22704 (0x58B0)
gaisser marked this conversation as resolved Outdated
Outdated
Review

Can you add a check for the resulting cds_short value, to find a reversible error in the conversions?

Can you add a check for the resulting cds_short value, to find a reversible error in the conversions?

Done

Done
CHECK(cdsTime.dayMSB == 0x58);
CHECK(cdsTime.dayLSB == 0xB0);
// MS of day 48285123.456 (floored here)
CHECK(cdsTime.msDay_hh == 0x2);
CHECK(cdsTime.msDay_h == 0xE0);
CHECK(cdsTime.msDay_l == 0xC5);
CHECK(cdsTime.msDay_ll == 0xC3);
// Conversion back to timeval
timeval timeReturnAsTimeval;
result = CCSDSTime::convertFromCDS(&timeReturnAsTimeval, &cdsTime);
CHECK(result == HasReturnvaluesIF::RETURN_OK);
// us precision is lost
// micro seconds precision is lost
timeval difference = timeAsTimeval - timeReturnAsTimeval;
CHECK(difference.tv_usec == 456);
CHECK(difference.tv_sec == 0);