summaryrefslogtreecommitdiff
path: root/tests/unit/jtty/test_jtty_live_entry.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-10-09 14:12:49 +0200
committerChristoph Berg <myon@debian.org>2026-10-09 14:12:49 +0200
commit76956486fa7ef52a51d4e56df1e13a9f19a6c93c (patch)
treefe0c394439fdc167d1970372e8998874090854dd /tests/unit/jtty/test_jtty_live_entry.cpp
parent0685fcada9f95fe90f70b387cd7d757da8209624 (diff)
parentffc62c792c9a5196cb4ce7a353287dfe20db6524 (diff)
Update upstream source from tag 'upstream/3.3.0_beta1+dfsg'
Update to upstream version '3.3.0~beta1+dfsg' with Debian dir 85037bbb9376721108594b59b54ead82ac6924a3
Diffstat (limited to 'tests/unit/jtty/test_jtty_live_entry.cpp')
-rw-r--r--tests/unit/jtty/test_jtty_live_entry.cpp86
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"