diff --git a/oscar/SleepLib/calcs.cpp b/oscar/SleepLib/calcs.cpp index 5a0c4d18..48f6f4ef 100644 --- a/oscar/SleepLib/calcs.cpp +++ b/oscar/SleepLib/calcs.cpp @@ -1254,8 +1254,7 @@ protected: } EventDataType findValueAtOrBefore(qint64 time) { - // curTime is always <= time, due to eventlist first/last search and m_curEvent reset. - qint64 curTime = m_curEventList->time(m_curEvent); + // m_curEvent is always <= time, due to eventlist first/last search and m_curEvent reset. for (quint32 i = m_curEvent + 1; i < m_curEventList->count(); i++) { qint64 nextTime = m_curEventList->time(i); if (nextTime > time) { @@ -1264,7 +1263,6 @@ protected: } // else nextTime <= time, advance m_curEvent = i; - curTime = nextTime; } EventDataType result = m_curEventList->data(m_curEvent); return result; diff --git a/oscar/tests/prs1tests.cpp b/oscar/tests/prs1tests.cpp index fe60f952..91cb7968 100644 --- a/oscar/tests/prs1tests.cpp +++ b/oscar/tests/prs1tests.cpp @@ -14,6 +14,7 @@ #include "../SleepLib/importcontext.h" #define TESTDATA_PATH "./testdata/" +//#define TEST_OSCAR_CALCS static PRS1Loader* s_loader = nullptr; static void iterateTestCards(const QString & root, void (*action)(const QString &)); @@ -24,6 +25,12 @@ void PRS1Tests::initTestCase(void) { p_profile = new Profile(TESTDATA_PATH "profile/", false); +#ifdef TEST_OSCAR_CALCS + p_pref = new Preferences("Preferences"); + p_pref->Open(); + AppSetting = new AppWideSetting(p_pref); +#endif + schema::init(); PRS1Loader::Register(); s_loader = dynamic_cast(lookupLoader(prs1_class_name)); @@ -33,6 +40,9 @@ void PRS1Tests::cleanupTestCase(void) { delete p_profile; p_profile = nullptr; +#ifdef TEST_OSCAR_CALCS + delete p_pref; +#endif } @@ -117,6 +127,10 @@ void parseAndEmitSessionYaml(const QString & path) // Emit the parsed session data to compare against our regression benchmarks Session* session = import->session; QString outpath = prs1OutputPath(path, m->serial(), session->session(), "-session.yml"); +#ifdef TEST_OSCAR_CALCS + session->s_events_loaded = true; + session->UpdateSummaries(); +#endif SessionToYaml(outpath, session, ok); delete session; diff --git a/oscar/tests/sessiontests.cpp b/oscar/tests/sessiontests.cpp index 110b927a..39b54bd9 100644 --- a/oscar/tests/sessiontests.cpp +++ b/oscar/tests/sessiontests.cpp @@ -196,6 +196,8 @@ static QString eventChannel(ChannelID i) CHANNELNAME(CPAP_FLG); CHANNELNAME(CPAP_AHI); CHANNELNAME(CPAP_TgMV); + // Calculated channels + CHANNELNAME(CPAP_RDI); s = hex(i); qDebug() << "event channel" << qPrintable(s); } while(false);