diff --git a/tests/blackmisc/testcontainers.cpp b/tests/blackmisc/testcontainers.cpp index db42a1e2b..d0f1b2f08 100644 --- a/tests/blackmisc/testcontainers.cpp +++ b/tests/blackmisc/testcontainers.cpp @@ -268,6 +268,43 @@ namespace BlackMiscTest } } + void CTestContainers::offsetTimestampList() + { + qsrand(QDateTime::currentDateTime().toTime_t()); + CAircraftSituationList situations; + qint64 ts = 1000000; + const int no = 10; + const int max = 6; + int dt = 0; + + for (int i = 0; i < no; ++i) + { + CAircraftSituation s; + s.setMSecsSinceEpoch(ts); + s.setCallsign("CS" + QString::number(i)); + + if (qrand() % 2 == 0) + { + // 4500-5500 + dt = 4500 + (qrand() % 1000); + s.setTimeOffsetMs(6000); + } + else + { + // 900-1100 + dt = 900 + (qrand() % 200); + s.setTimeOffsetMs(2000); + } + + ts += dt; + situations.push_frontKeepLatestFirstAdjustOffset(s, max); + + QVERIFY2(situations.size() <= max, "Wrong size"); + QVERIFY2(situations.isSortedAdjustedLatestFirst(), "Wrong sort order"); + QVERIFY2(!situations.hasInvalidTimestamps(), "Missing timestamps"); + QVERIFY2(!situations.containsZeroOrNegativeOffsetTime(), "Missing offset time"); + } + } } //namespace //! \endcond diff --git a/tests/blackmisc/testcontainers.h b/tests/blackmisc/testcontainers.h index 0ac58e916..d55a82123 100644 --- a/tests/blackmisc/testcontainers.h +++ b/tests/blackmisc/testcontainers.h @@ -34,6 +34,7 @@ namespace BlackMiscTest void findTests(); void dictionaryBasics(); void timestampList(); + void offsetTimestampList(); }; } // namespace