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/common/test_fox_guard_bands.cpp | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'tests/unit/common/test_fox_guard_bands.cpp')
| -rw-r--r-- | tests/unit/common/test_fox_guard_bands.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/tests/unit/common/test_fox_guard_bands.cpp b/tests/unit/common/test_fox_guard_bands.cpp new file mode 100644 index 00000000..a7d1839c --- /dev/null +++ b/tests/unit/common/test_fox_guard_bands.cpp @@ -0,0 +1,92 @@ +#include <QtTest> + +#include "FoxGuardBands.hpp" + +class TestFoxGuardBands + : public QObject +{ + Q_OBJECT + +private: + Q_SLOT void standard_ft8_first_and_last_guards_block () + { + auto const first = FoxGuardBands::check (1840000); + QVERIFY (first.blocked); + QCOMPARE (static_cast<int> (first.kind), static_cast<int> (FoxGuardBands::GuardKind::StandardFT8)); + QCOMPARE (first.guard_frequency, Radio::Frequency {1840000}); + + auto const last = FoxGuardBands::check (70154000); + QVERIFY (last.blocked); + QCOMPARE (static_cast<int> (last.kind), static_cast<int> (FoxGuardBands::GuardKind::StandardFT8)); + QCOMPARE (last.guard_frequency, Radio::Frequency {70154000}); + } + + Q_SLOT void wspr_first_and_last_guards_block () + { + auto const first = FoxGuardBands::check (1836600); + QVERIFY (first.blocked); + QCOMPARE (static_cast<int> (first.kind), static_cast<int> (FoxGuardBands::GuardKind::WSPR)); + QCOMPARE (first.guard_frequency, Radio::Frequency {1836600}); + + auto const last = FoxGuardBands::check (28124600); + QVERIFY (last.blocked); + QCOMPARE (static_cast<int> (last.kind), static_cast<int> (FoxGuardBands::GuardKind::WSPR)); + QCOMPARE (last.guard_frequency, Radio::Frequency {28124600}); + } + + Q_SLOT void standard_ft8_boundaries_are_exclusive_at_3000_hz () + { + auto const below = FoxGuardBands::check (14074000 - 2999); + QVERIFY (below.blocked); + QCOMPARE (static_cast<int> (below.kind), static_cast<int> (FoxGuardBands::GuardKind::StandardFT8)); + QCOMPARE (below.guard_frequency, Radio::Frequency {14074000}); + + auto const above = FoxGuardBands::check (14074000 + 2999); + QVERIFY (above.blocked); + QCOMPARE (static_cast<int> (above.kind), static_cast<int> (FoxGuardBands::GuardKind::StandardFT8)); + QCOMPARE (above.guard_frequency, Radio::Frequency {14074000}); + + QVERIFY (!FoxGuardBands::check (14074000 - 3000).blocked); + QVERIFY (!FoxGuardBands::check (14074000 + 3000).blocked); + } + + Q_SLOT void wspr_boundaries_match_existing_thresholds () + { + auto const guard_frequency = Radio::Frequency {28124600}; + + auto const lower = FoxGuardBands::check (guard_frequency - 3499); + QVERIFY (lower.blocked); + QCOMPARE (static_cast<int> (lower.kind), static_cast<int> (FoxGuardBands::GuardKind::WSPR)); + QCOMPARE (lower.guard_frequency, guard_frequency); + + auto const upper = FoxGuardBands::check (guard_frequency + 299); + QVERIFY (upper.blocked); + QCOMPARE (static_cast<int> (upper.kind), static_cast<int> (FoxGuardBands::GuardKind::WSPR)); + QCOMPARE (upper.guard_frequency, guard_frequency); + + QVERIFY (!FoxGuardBands::check (guard_frequency - 3500).blocked); + QVERIFY (!FoxGuardBands::check (guard_frequency + 300).blocked); + } + + Q_SLOT void standard_ft8_match_wins_over_wspr_match () + { + auto const match = FoxGuardBands::check (1000000, {1000000}, {1000000}); + + QVERIFY (match.blocked); + QCOMPARE (static_cast<int> (match.kind), static_cast<int> (FoxGuardBands::GuardKind::StandardFT8)); + QCOMPARE (match.guard_frequency, Radio::Frequency {1000000}); + } + + Q_SLOT void unrelated_frequency_is_unblocked () + { + auto const match = FoxGuardBands::check (123456789); + + QVERIFY (!match.blocked); + QCOMPARE (static_cast<int> (match.kind), static_cast<int> (FoxGuardBands::GuardKind::None)); + QCOMPARE (match.guard_frequency, Radio::Frequency {0}); + } +}; + +QTEST_MAIN (TestFoxGuardBands); + +#include "test_fox_guard_bands.moc" |
