diff options
| author | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
| commit | ffc62c792c9a5196cb4ce7a353287dfe20db6524 (patch) | |
| tree | 1269efa852935b183daae4bb33a58d1b4d2ffb53 /tests/unit/qmap/test_livecq_parser.cpp | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
New upstream version 3.3.0~beta1+dfsgupstream/3.3.0_beta1+dfsg
Diffstat (limited to 'tests/unit/qmap/test_livecq_parser.cpp')
| -rw-r--r-- | tests/unit/qmap/test_livecq_parser.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/unit/qmap/test_livecq_parser.cpp b/tests/unit/qmap/test_livecq_parser.cpp index 4f0ff9ea..e3fc7f23 100644 --- a/tests/unit/qmap/test_livecq_parser.cpp +++ b/tests/unit/qmap/test_livecq_parser.cpp @@ -77,6 +77,58 @@ private slots: {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "DX", "N5", "1200.0"}, 100, record)); } + + void spotTimeUsesTodaysUtcDate() + { + QDateTime const now {QDate {2026, 9, 30}, QTime {18, 7, 10}, Qt::UTC}; + QCOMPARE(QMapLiveCQ::spotTime("180630", now), + QDateTime(QDate {2026, 9, 30}, QTime {18, 6, 30}, Qt::UTC)); + QCOMPARE(QMapLiveCQ::spotTime("1806", now), + QDateTime(QDate {2026, 9, 30}, QTime {18, 6}, Qt::UTC)); + QCOMPARE(QMapLiveCQ::spotTime("180630", now).toString("yyyy-MM-ddTHH:mm:ss") + "Z", + QString {"2026-09-30T18:06:30Z"}); + } + + void spotTimeIsIndependentOfLocale() + { + QDateTime const now {QDate {2026, 9, 30}, QTime {18, 7, 10}, Qt::UTC}; + auto const previous = QLocale {}; + for (auto const name : {"cs_CZ", "es_AR", "hu_HU", "fr_FR", "de_DE", "zh_TW", "ru_RU"}) { + QLocale::setDefault(QLocale {name}); + QCOMPARE(QMapLiveCQ::spotTime("180630", now).toString("yyyy-MM-ddTHH:mm:ss") + "Z", + QString {"2026-09-30T18:06:30Z"}); + } + QLocale::setDefault(previous); + } + + void spotTimeAcrossMidnight() + { + // Early decode of the last period before midnight: still the same day. + QCOMPARE(QMapLiveCQ::spotTime("235930", QDateTime(QDate {2026, 9, 30}, QTime {23, 59, 52}, Qt::UTC)), + QDateTime(QDate {2026, 9, 30}, QTime {23, 59, 30}, Qt::UTC)); + // Decoded just after midnight: the period began yesterday. + QCOMPARE(QMapLiveCQ::spotTime("235900", QDateTime(QDate {2026, 10, 1}, QTime {0, 0, 5}, Qt::UTC)), + QDateTime(QDate {2026, 9, 30}, QTime {23, 59}, Qt::UTC)); + QCOMPARE(QMapLiveCQ::spotTime("235930", QDateTime(QDate {2026, 10, 1}, QTime {0, 0, 22}, Qt::UTC)), + QDateTime(QDate {2026, 9, 30}, QTime {23, 59, 30}, Qt::UTC)); + // First period of the new day. + QCOMPARE(QMapLiveCQ::spotTime("000000", QDateTime(QDate {2026, 10, 1}, QTime {0, 0, 52}, Qt::UTC)), + QDateTime(QDate {2026, 10, 1}, QTime {0, 0}, Qt::UTC)); + // Clock a few seconds behind the decoder: not pushed back a day. + QCOMPARE(QMapLiveCQ::spotTime("120000", QDateTime(QDate {2026, 9, 30}, QTime {11, 59, 58}, Qt::UTC)), + QDateTime(QDate {2026, 9, 30}, QTime {12, 0}, Qt::UTC)); + } + + void spotTimeRejectsMalformedTimes() + { + QDateTime const now {QDate {2026, 9, 30}, QTime {18, 7, 10}, Qt::UTC}; + for (auto const& decodeTime : {QString {}, QString {"123"}, QString {"1234567"}, + QString {"2460"}, QString {"1260"}, QString {"126099"}, + QString {"12x4"}, QString {"12:34"}}) { + QVERIFY(!QMapLiveCQ::spotTime(decodeTime, now).isValid()); + } + QVERIFY(!QMapLiveCQ::spotTime("123456", QDateTime {}).isValid()); + } }; QTEST_APPLESS_MAIN(TestQMapLiveCQParser) |
