diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
| commit | 059831534c7e884f0a607ed86b582fd00d821731 (patch) | |
| tree | 76bcb67a78f8aa2654fd34c2ad801a62136b0170 /tests/unit/band_hopping | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'tests/unit/band_hopping')
| -rw-r--r-- | tests/unit/band_hopping/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | tests/unit/band_hopping/test_band_hopping.cpp | 52 |
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" |
