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_fox_operator_actions.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_fox_operator_actions.cpp')
| -rw-r--r-- | tests/unit/common/test_fox_operator_actions.cpp | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/tests/unit/common/test_fox_operator_actions.cpp b/tests/unit/common/test_fox_operator_actions.cpp new file mode 100644 index 00000000..f6870fa1 --- /dev/null +++ b/tests/unit/common/test_fox_operator_actions.cpp @@ -0,0 +1,124 @@ +#include <QMap> +#include <QQueue> +#include <QTest> + +#include "FoxOperatorActions.hpp" + +namespace +{ + QString queueLine (QString const& call, QString const& details) + { + return (call + QString (12, ' ')).left (12) + details; + } + + struct Qso + { + int ncall; + int sentinel; + }; +} + +class TestFoxOperatorActions final + : public QObject +{ + Q_OBJECT + +private slots: + void moveToFrontUsesLiveQueueLine () + { + auto const first = queueLine ("W1AAA", "-02 FN31"); + auto const live_target = queueLine ("K1ABC", "+04 FN42"); + QQueue<QString> queue; + queue.enqueue (first); + queue.enqueue (live_target); + + QVERIFY (FoxOperatorActions::moveQueuedHoundToFront ( + queue, queueLine ("K1ABC", "+01 stale snapshot"))); + + QCOMPARE (queue.size (), 2); + QCOMPARE (queue.at (0), live_target); + QCOMPARE (queue.at (1), first); + } + + void moveToFrontRejectsMissingHound () + { + auto const live_line = queueLine ("W1AAA", "-02 FN31"); + QQueue<QString> queue; + queue.enqueue (live_line); + + QVERIFY (!FoxOperatorActions::moveQueuedHoundToFront ( + queue, queueLine ("K1ABC", "+01 stale snapshot"))); + + QCOMPARE (queue.size (), 1); + QCOMPARE (queue.at (0), live_line); + } + + void removeUsesLiveQueueCallsign () + { + auto const retained = queueLine ("W1AAA", "-02 FN31"); + QQueue<QString> queue; + queue.enqueue (retained); + queue.enqueue (queueLine ("K1ABC", "+04 FN42")); + queue.enqueue (queueLine ("K1ABC", "+02 FN41")); + + QVERIFY (FoxOperatorActions::removeQueuedHound ( + queue, queueLine ("K1ABC", "+01 stale snapshot"))); + + QCOMPARE (queue.size (), 1); + QCOMPARE (queue.at (0), retained); + } + + void removeRejectsMissingHound () + { + auto const live_line = queueLine ("W1AAA", "-02 FN31"); + QQueue<QString> queue; + queue.enqueue (live_line); + + QVERIFY (!FoxOperatorActions::removeQueuedHound ( + queue, queueLine ("K1ABC", "+01 stale snapshot"))); + + QCOMPARE (queue.size (), 1); + QCOMPARE (queue.at (0), live_line); + } + + void timeoutRequiresActiveCallAndQso () + { + QQueue<QString> in_progress; + in_progress.enqueue ("K1ABC"); + QMap<QString, Qso> qsos {{"K1ABC", {2, 73}}}; + + QVERIFY (FoxOperatorActions::timeoutIfActive ( + in_progress, qsos, queueLine ("K1ABC", "3 (rx)"), 6)); + + QCOMPARE (qsos.value ("K1ABC").ncall, 6); + QCOMPARE (qsos.value ("K1ABC").sentinel, 73); + } + + void timeoutRejectsCallNoLongerInProgress () + { + QQueue<QString> in_progress; + QMap<QString, Qso> qsos {{"K1ABC", {2, 73}}}; + + QVERIFY (!FoxOperatorActions::timeoutIfActive ( + in_progress, qsos, queueLine ("K1ABC", "3 (rx)"), 6)); + + QCOMPARE (qsos.value ("K1ABC").ncall, 2); + QCOMPARE (qsos.value ("K1ABC").sentinel, 73); + } + + void timeoutDoesNotCreateMissingQso () + { + QQueue<QString> in_progress; + in_progress.enqueue ("K1ABC"); + QMap<QString, Qso> qsos; + + QVERIFY (!FoxOperatorActions::timeoutIfActive ( + in_progress, qsos, queueLine ("K1ABC", "3 (rx)"), 6)); + + QVERIFY (qsos.isEmpty ()); + } +}; + +QTEST_MAIN (TestFoxOperatorActions) + +#include "test_fox_operator_actions.moc" |
