summaryrefslogtreecommitdiff
path: root/tests/unit/qmap/test_livecq_parser.cpp
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2026-10-20 22:35:06 +0100
committerDave Hibberd <hibby@debian.org>2026-10-20 22:35:06 +0100
commit82ebb1ed1af30cee4dfbb1c628431d32885a00e0 (patch)
tree1a1f782d3e576b758be0bc61171574a7cd8f2376 /tests/unit/qmap/test_livecq_parser.cpp
parent061658210acb6425517733ea012dda803a7f72a1 (diff)
parent61d684922b0f1c8455cc60eb3d123df058c9e1f5 (diff)
Merge tag 'debian/3.3.0_beta2+dfsg-1' into hibbian/trixie-backports
tagging wsjtx 3.3.0~beta2+dfsg-1
Diffstat (limited to 'tests/unit/qmap/test_livecq_parser.cpp')
-rw-r--r--tests/unit/qmap/test_livecq_parser.cpp52
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)