diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /tests/unit/common/QsoReactionTestSupport.hpp | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (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/QsoReactionTestSupport.hpp')
| -rw-r--r-- | tests/unit/common/QsoReactionTestSupport.hpp | 71 |
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 |
