summaryrefslogtreecommitdiff
path: root/tests/unit/qmap/test_livecq_parser.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
commit059831534c7e884f0a607ed86b582fd00d821731 (patch)
tree76bcb67a78f8aa2654fd34c2ad801a62136b0170 /tests/unit/qmap/test_livecq_parser.cpp
parentd83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff)
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
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"