summaryrefslogtreecommitdiff
path: root/tests/unit/common/QsoReactionTestSupport.hpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
commit69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch)
treeebc98370a697a9bbd6b973a14fa5113c475c6db7 /tests/unit/common/QsoReactionTestSupport.hpp
parent3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff)
parent059831534c7e884f0a607ed86b582fd00d821731 (diff)
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg' with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
Diffstat (limited to 'tests/unit/common/QsoReactionTestSupport.hpp')
-rw-r--r--tests/unit/common/QsoReactionTestSupport.hpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/unit/common/QsoReactionTestSupport.hpp b/tests/unit/common/QsoReactionTestSupport.hpp
new file mode 100644
index 00000000..c344ed2a
--- /dev/null
+++ b/tests/unit/common/QsoReactionTestSupport.hpp
@@ -0,0 +1,71 @@
+#ifndef QSOREACTIONTESTSUPPORT_HPP
+#define QSOREACTIONTESTSUPPORT_HPP
+
+#include "DecodedMessageReaction.hpp"
+#include "Decoder/decodedtext.h"
+
+namespace QsoReactionTestSupport
+{
+ using Effect = DecodedMessageReaction::QsoReactionEffect;
+ using Plan = DecodedMessageReaction::QsoReactionPlan;
+ using Snapshot = DecodedMessageReaction::QsoReactionSnapshot;
+
+ inline DecodedText decode(QString const& payload, QString const& marker = "~",
+ QString const& time = "0605", int frequency = 1500)
+ {
+ return DecodedText {
+ QString {"%1 -10 0.3 %2 %3 %4"}
+ .arg(time).arg(frequency, 4, 10, QChar {'0'}).arg(marker).arg(payload)};
+ }
+
+ inline Snapshot neutralStationSnapshot()
+ {
+ Snapshot snapshot;
+ snapshot.myCall = "K1ABC";
+ snapshot.baseCall = "K1ABC";
+ snapshot.dxCall = "W1AW";
+ snapshot.hisCall = "W1AW";
+ snapshot.hisGrid = "FN31";
+ snapshot.trPeriod = 15.0;
+ snapshot.nominalFrequency = 14074000;
+ snapshot.rxFrequency = 1500;
+ snapshot.txFrequency = 1500;
+ return snapshot;
+ }
+
+ inline int effectIndex(Plan const& plan, Effect::Kind kind, int from = 0)
+ {
+ for (int i = from; i < plan.effects.size(); ++i) {
+ if (plan.effects[i].kind == kind) return i;
+ }
+ return -1;
+ }
+
+ inline int effectCount(Plan const& plan, Effect::Kind kind)
+ {
+ int count = 0;
+ for (auto const& effect : plan.effects) {
+ if (effect.kind == kind) ++count;
+ }
+ return count;
+ }
+
+ inline bool hasEffect(Plan const& plan, Effect::Kind kind)
+ {
+ return effectIndex(plan, kind) >= 0;
+ }
+
+ inline int intEffect(Plan const& plan, Effect::Kind kind, int defaultValue = -1)
+ {
+ int const index = effectIndex(plan, kind);
+ return index >= 0 ? plan.effects[index].intValue : defaultValue;
+ }
+
+ inline QString textEffect(Plan const& plan, Effect::Kind kind)
+ {
+ int const index = effectIndex(plan, kind);
+ return index >= 0 ? plan.effects[index].text : QString {};
+ }
+}
+
+#endif // QSOREACTIONTESTSUPPORT_HPP