summaryrefslogtreecommitdiff
path: root/tests/unit/band_hopping/test_band_hopping.cpp
blob: 6555b149ef6530b166b04e9d5c223433a2ac55ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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"