diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
| commit | 69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch) | |
| tree | ebc98370a697a9bbd6b973a14fa5113c475c6db7 /tests/unit/common/test_callsign_validator.cpp | |
| parent | 3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff) | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg'
with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
Diffstat (limited to 'tests/unit/common/test_callsign_validator.cpp')
| -rw-r--r-- | tests/unit/common/test_callsign_validator.cpp | 48 |
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" |
