summaryrefslogtreecommitdiff
path: root/tests/unit/common/test_hamlib_vfo_role_state.cpp
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/common/test_hamlib_vfo_role_state.cpp
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/common/test_hamlib_vfo_role_state.cpp')
-rw-r--r--tests/unit/common/test_hamlib_vfo_role_state.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/unit/common/test_hamlib_vfo_role_state.cpp b/tests/unit/common/test_hamlib_vfo_role_state.cpp
new file mode 100644
index 00000000..44edb39a
--- /dev/null
+++ b/tests/unit/common/test_hamlib_vfo_role_state.cpp
@@ -0,0 +1,83 @@
+#include <tuple>
+
+#include <QtTest>
+
+#include "Transceiver/HamlibVfoRoleState.hpp"
+
+class TestHamlibVfoRoleState : public QObject
+{
+ Q_OBJECT
+
+private:
+ Q_SLOT void receivingOnVfoAUsesNormalRoles ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_A, false);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_A);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_B);
+ }
+
+ Q_SLOT void receivingOnVfoBReversesRoles ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_B, false);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_B);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_A);
+ }
+
+ Q_SLOT void splitPttPreservesNormalRoles ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_A, false);
+ state.observe_active_vfo (RIG_VFO_B, true);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_A);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_B);
+ }
+
+ Q_SLOT void splitPttPreservesReversedRoles ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_B, false);
+ state.observe_active_vfo (RIG_VFO_A, true);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_B);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_A);
+ }
+
+ Q_SLOT void observationResumesAfterSplitPtt ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_A, false);
+ state.observe_active_vfo (RIG_VFO_B, true);
+ state.observe_active_vfo (RIG_VFO_B, false);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_B);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_A);
+ }
+
+ Q_SLOT void resetRestoresNormalRoles ()
+ {
+ HamlibVfoRoleState state;
+ auto vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_A);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_B);
+
+ state.observe_active_vfo (RIG_VFO_B, false);
+ state.reset ();
+
+ vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_A);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_B);
+ }
+};
+
+QTEST_APPLESS_MAIN (TestHamlibVfoRoleState)
+#include "test_hamlib_vfo_role_state.moc"