summaryrefslogtreecommitdiff
path: root/tests/unit/common/test_callsign_validator.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/common/test_callsign_validator.cpp
parentd83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff)
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'tests/unit/common/test_callsign_validator.cpp')
-rw-r--r--tests/unit/common/test_callsign_validator.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/unit/common/test_callsign_validator.cpp b/tests/unit/common/test_callsign_validator.cpp
new file mode 100644
index 00000000..6715dfd7
--- /dev/null
+++ b/tests/unit/common/test_callsign_validator.cpp
@@ -0,0 +1,48 @@
+#include <QtTest>
+
+#include "validators/CallsignValidator.hpp"
+
+class TestCallsignValidator final
+ : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void normalizeStoredInput_data ();
+ void normalizeStoredInput ();
+};
+
+void TestCallsignValidator::normalizeStoredInput_data ()
+{
+ QTest::addColumn<QString> ("input");
+ QTest::addColumn<int> ("max_length");
+ QTest::addColumn<bool> ("allow_compound");
+ QTest::addColumn<QString> ("expected");
+
+ QTest::newRow ("valid") << QString {"K1JT"} << 6 << false << QString {"K1JT"};
+ QTest::newRow ("lowercase") << QString {"k1jt"} << 6 << false << QString {"K1JT"};
+ QTest::newRow ("boundary whitespace") << QString {" k1jt "} << 6 << false << QString {"K1JT"};
+ QTest::newRow ("trim before truncation") << QString {" K1JT73"} << 6 << false << QString {"K1JT73"};
+ QTest::newRow ("truncate valid") << QString {"K1JT73X"} << 6 << false << QString {"K1JT73"};
+ QTest::newRow ("compound allowed") << QString {"K1JT/P"} << 6 << true << QString {"K1JT/P"};
+ QTest::newRow ("compound rejected") << QString {"K1JT/P"} << 6 << false << QString {};
+ QTest::newRow ("punctuation") << QString {"K1?JT"} << 6 << false << QString {};
+ QTest::newRow ("internal whitespace") << QString {"K1 JT"} << 6 << false << QString {};
+ QTest::newRow ("non-ASCII") << QString::fromUtf8 ("K1\xc3\x98JT") << 6 << false << QString {};
+ QTest::newRow ("empty") << QString {} << 6 << false << QString {};
+}
+
+void TestCallsignValidator::normalizeStoredInput ()
+{
+ QFETCH (QString, input);
+ QFETCH (int, max_length);
+ QFETCH (bool, allow_compound);
+ QFETCH (QString, expected);
+
+ QCOMPARE (CallsignValidator::normalizeStoredInput (
+ input, max_length, allow_compound), expected);
+}
+
+QTEST_GUILESS_MAIN (TestCallsignValidator)
+
+#include "test_callsign_validator.moc"