summaryrefslogtreecommitdiff
path: root/tests/unit/band_hopping
diff options
context:
space:
mode:
authorhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
committerhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
commitc25cbdf6fb6d946175f4335fab77bfea601b56db (patch)
tree6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /tests/unit/band_hopping
parent71f5689252c9f13e70e1c24856904475b2307809 (diff)
parent0685fcada9f95fe90f70b387cd7d757da8209624 (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/band_hopping')
-rw-r--r--tests/unit/band_hopping/CMakeLists.txt6
-rw-r--r--tests/unit/band_hopping/test_band_hopping.cpp52
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/unit/band_hopping/CMakeLists.txt b/tests/unit/band_hopping/CMakeLists.txt
new file mode 100644
index 00000000..94d7485a
--- /dev/null
+++ b/tests/unit/band_hopping/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_executable (test_band_hopping
+ test_band_hopping.cpp
+ ${CMAKE_SOURCE_DIR}/widgets/BandHopping.cpp
+)
+target_link_libraries (test_band_hopping Qt5::Test)
+add_test (NAME test_band_hopping COMMAND test_band_hopping)
diff --git a/tests/unit/band_hopping/test_band_hopping.cpp b/tests/unit/band_hopping/test_band_hopping.cpp
new file mode 100644
index 00000000..6555b149
--- /dev/null
+++ b/tests/unit/band_hopping/test_band_hopping.cpp
@@ -0,0 +1,52 @@
+#include <QtTest>
+
+#include "widgets/BandHopping.hpp"
+
+class TestBandHopping
+ : public QObject
+{
+ Q_OBJECT
+
+private:
+ Q_SLOT void empty_selection_returns_no_hop ()
+ {
+ QCOMPARE (next_band_hop_index ({false, false, false}, 0), -1);
+ }
+
+ Q_SLOT void single_selection_returns_same_entry ()
+ {
+ std::vector<bool> const selected {false, true, false};
+
+ QCOMPARE (next_band_hop_index (selected, 0), 1);
+ QCOMPARE (next_band_hop_index (selected, 1), 1);
+ QCOMPARE (next_band_hop_index (selected, 2), 1);
+ }
+
+ Q_SLOT void multiple_selections_advance_from_start ()
+ {
+ std::vector<bool> const selected {false, true, false, true};
+
+ QCOMPARE (next_band_hop_index (selected, 0), 1);
+ QCOMPARE (next_band_hop_index (selected, 2), 3);
+ }
+
+ Q_SLOT void selection_wraps_after_end ()
+ {
+ std::vector<bool> const selected {true, false, false, true};
+
+ QCOMPARE (next_band_hop_index (selected, 4), 0);
+ QCOMPARE (next_band_hop_index (selected, 5), 3);
+ }
+
+ Q_SLOT void start_index_normalizes_safely ()
+ {
+ std::vector<bool> const selected {false, false, true};
+
+ QCOMPARE (next_band_hop_index (selected, -1), 2);
+ QCOMPARE (next_band_hop_index (selected, 8), 2);
+ }
+};
+
+QTEST_MAIN (TestBandHopping);
+
+#include "test_band_hopping.moc"