diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /tests/unit/common/test_callsign_validator.cpp | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (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/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" |
