summaryrefslogtreecommitdiff
path: root/tests/unit/qmap/test_livecq_parser.cpp
diff options
context:
space:
mode:
authorhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
committerhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
commitc25cbdf6fb6d946175f4335fab77bfea601b56db (patch)
tree6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /tests/unit/qmap/test_livecq_parser.cpp
parent71f5689252c9f13e70e1c24856904475b2307809 (diff)
parent0685fcada9f95fe90f70b387cd7d757da8209624 (diff)
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'tests/unit/qmap/test_livecq_parser.cpp')
-rw-r--r--tests/unit/qmap/test_livecq_parser.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/unit/qmap/test_livecq_parser.cpp b/tests/unit/qmap/test_livecq_parser.cpp
new file mode 100644
index 00000000..4f0ff9ea
--- /dev/null
+++ b/tests/unit/qmap/test_livecq_parser.cpp
@@ -0,0 +1,84 @@
+#include <QtTest>
+
+#include "qmap/livecq_parser.h"
+
+class TestQMapLiveCQParser final : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void parsesSupportedLayouts()
+ {
+ QMapLiveCQ::Record record;
+ QVERIFY(QMapLiveCQ::parse(
+ {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "N5L", "1200.0"},
+ 100, record));
+ QCOMPARE(record.callsign, QString {"N5L"});
+ QCOMPARE(record.grid, QString {"--"});
+ QCOMPARE(record.message, QString {"CQ N5L"});
+ QCOMPARE(record.receiveFrequency, 100);
+ QCOMPARE(record.scheduledFrequency, 1200);
+
+ QVERIFY(QMapLiveCQ::parse(
+ {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "N5L", "FN20", "1200.0"},
+ 100, record));
+ QCOMPARE(record.grid, QString {"FN20"});
+ QCOMPARE(record.message, QString {"CQ N5L FN20"});
+
+ QVERIFY(QMapLiveCQ::parse(
+ {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "DX", "N5L", "1200.0"},
+ 100, record));
+ QCOMPARE(record.callsign, QString {"N5L"});
+ QCOMPARE(record.grid, QString {"--"});
+ QCOMPARE(record.message, QString {"CQ N5L"});
+
+ QVERIFY(QMapLiveCQ::parse(
+ {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "DX", "N5L", "FN20", "1200.0"},
+ 100, record));
+ QCOMPARE(record.grid, QString {"FN20"});
+ QCOMPARE(record.message, QString {"CQ N5L FN20"});
+ }
+
+ void parsesHighFrequencyFraction()
+ {
+ QMapLiveCQ::Record record;
+ QVERIFY(QMapLiveCQ::parse(
+ {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "N5L", "1200.750"},
+ 100, record));
+ QCOMPARE(record.receiveFrequency, -150);
+ QCOMPARE(record.scheduledFrequency, 1201);
+ }
+
+ void rejectsMalformedRecordsBeforeIndexing()
+ {
+ QMapLiveCQ::Record record;
+ for (auto const& tokens : {
+ QStringList {},
+ QStringList {"123456", "-10", "0.1", "1234", "-12", "60", "CQ"},
+ QStringList {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "N5L"},
+ QStringList {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "N5L", "FN20", "1200.0", "extra", "too-much"}}) {
+ QVERIFY(!QMapLiveCQ::parse(tokens, 100, record));
+ }
+ }
+
+ void rejectsMalformedFrequencyAndCalls()
+ {
+ QMapLiveCQ::Record record;
+ for (auto const& frequency : {QString {"1200"}, QString {"1200."},
+ QString {"1200.x"}, QString {"1200.0.1"}}) {
+ QVERIFY(!QMapLiveCQ::parse(
+ {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "N5L", frequency},
+ 100, record));
+ }
+ QVERIFY(!QMapLiveCQ::parse(
+ {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "N5", "1200.0"},
+ 100, record));
+ QVERIFY(!QMapLiveCQ::parse(
+ {"123456", "-10", "0.1", "1234", "-12", "60", "CQ", "DX", "N5", "1200.0"},
+ 100, record));
+ }
+};
+
+QTEST_APPLESS_MAIN(TestQMapLiveCQParser)
+
+#include "test_livecq_parser.moc"