diff options
| author | Dave Hibberd <hibby@debian.org> | 2026-10-20 22:35:06 +0100 |
|---|---|---|
| committer | Dave Hibberd <hibby@debian.org> | 2026-10-20 22:35:06 +0100 |
| commit | 82ebb1ed1af30cee4dfbb1c628431d32885a00e0 (patch) | |
| tree | 1a1f782d3e576b758be0bc61171574a7cd8f2376 /tests/unit/jtty/test_jtty_live_entry.cpp | |
| parent | 061658210acb6425517733ea012dda803a7f72a1 (diff) | |
| parent | 61d684922b0f1c8455cc60eb3d123df058c9e1f5 (diff) | |
Merge tag 'debian/3.3.0_beta2+dfsg-1' into hibbian/trixie-backports
tagging wsjtx 3.3.0~beta2+dfsg-1
Diffstat (limited to 'tests/unit/jtty/test_jtty_live_entry.cpp')
| -rw-r--r-- | tests/unit/jtty/test_jtty_live_entry.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/unit/jtty/test_jtty_live_entry.cpp b/tests/unit/jtty/test_jtty_live_entry.cpp new file mode 100644 index 00000000..9f9f7d2f --- /dev/null +++ b/tests/unit/jtty/test_jtty_live_entry.cpp @@ -0,0 +1,86 @@ +#include <QtTest> + +#include "widgets/JttyLiveEntry.hpp" + +class TestJttyLiveEntry final + : public QObject +{ + Q_OBJECT + +private slots: + + void emptyTextCommitsNothing () + { + auto const plan = Jtty::planIncrementalCommit (QString {}); + QVERIFY (plan.text.isEmpty ()); + QCOMPARE (plan.length, 0); + } + + void fewerThanHoldbackWordsCommitsNothing () + { + // Exactly maxCompactAtomWords complete words: still all held back. + auto const plan = Jtty::planIncrementalCommit (QStringLiteral ("CQ K1ABC CQ ")); + QVERIFY (plan.text.isEmpty ()); + QCOMPARE (plan.length, 0); + } + + void callSplitAcrossHoldbackNeverCommitsPartway () + { + // The motivating case: TEXT5's fixed 5-char windows would slice "CQ K1ABC" mid-callsign if released early. + for (auto const& text : {QStringLiteral ("CQ "), QStringLiteral ("CQ K1ABC ")}) { + auto const plan = Jtty::planIncrementalCommit (text); + QVERIFY2 (plan.text.isEmpty (), qPrintable (text)); + } + } + + void wordBeyondHoldbackReleasesOnlyTheEarlierWords () + { + // A 4th word pushes the first word out past the 3-word holdback. + auto const plan = Jtty::planIncrementalCommit ( + QStringLiteral ("CQ K1ABC CQ DE ")); + QCOMPARE (plan.text, QStringLiteral ("CQ ")); + QCOMPARE (plan.length, 3); + } + + void releasedPrefixExactlyMatchesOriginalText () + { + QString const text = QStringLiteral ("FIRST SECOND THIRD FOURTH FIFTH "); + auto const plan = Jtty::planIncrementalCommit (text); + QCOMPARE (text.left (plan.length), plan.text); + // 5 complete words, holdback 3: releases the first 2. + QCOMPARE (plan.text, QStringLiteral ("FIRST SECOND ")); + } + + void trailingPartialWordIsNeverReleased () + { + // Same words as the previous case, but the 5th is still mid-typing (no trailing space), so only 4 are complete. + auto const plan = Jtty::planIncrementalCommit ( + QStringLiteral ("FIRST SECOND THIRD FOURTH FIF")); + QCOMPARE (plan.text, QStringLiteral ("FIRST ")); + } + + void forceFlushReleasesEverythingRegardlessOfHoldback () + { + QString const text = QStringLiteral ("CQ K1ABC"); + auto const plan = Jtty::planIncrementalCommit (text, true); + QCOMPARE (plan.text, text); + QCOMPARE (plan.length, text.size ()); + } + + void forceFlushOnEmptyTextCommitsNothing () + { + auto const plan = Jtty::planIncrementalCommit (QString {}, true); + QVERIFY (plan.text.isEmpty ()); + QCOMPARE (plan.length, 0); + } + + void customHoldbackIsHonoured () + { + auto const plan = Jtty::planIncrementalCommit ( + QStringLiteral ("ONE TWO THREE "), false, 1); + QCOMPARE (plan.text, QStringLiteral ("ONE TWO ")); + } +}; + +QTEST_GUILESS_MAIN (TestJttyLiveEntry) +#include "test_jtty_live_entry.moc" |
