Background
The ATU pre-tune sweep landed in #2630 has a pure-math `computeCenters(double lowMhz, double highMhz, int segmentKhz) → QVector` helper in `AtuPreTuneDialog.cpp` that generates the per-band sweep points. The issue body for #2624 included an explicit reference table for IARU Region 1 (160m=23 points, 80m=34, 60m=2, 40m=8, 30m=2, 20m=7, 17m=2, 15m=6, 12m=2, 10m=23, 6m=20 — 129 total) which is exactly the kind of fixed-point oracle a small unit test should lock in.
The function isn't currently covered by any test. Adding one would:
- Catch regressions if the algorithm gets touched (rounding, clamping, off-by-one on the last-segment clamp).
- Document the expected output for each band size mathematically rather than via hand-verification at PR-review time.
Fix
Add `tests/atu_pretune_centers_test.cpp` with assertions like:
```cpp
// IARU R1 reference (from issue #2624)
expect(computeCenters(1.800, 2.000, 9).size() == 23, "160m IARU R1 → 23 points");
expect(qFuzzyCompare(computeCenters(1.800, 2.000, 9).first(), 1.8045), "160m first center 1804.5 kHz");
expect(computeCenters(14.000, 14.350, 51).size() == 7, "20m IARU R1 → 7 points");
// ... one row per band in the reference table
// Plus edge cases:
expect(computeCenters(5.3515, 5.3665, 9).size() == 2, "60m clamp last center");
expect(computeCenters(0.0, 0.0, 9).isEmpty(), "zero range returns empty");
expect(computeCenters(14.0, 14.001, 51).isEmpty(), "range smaller than segment returns empty");
```
Register the executable in `CMakeLists.txt` next to the other `test` harnesses (e.g. `antenna_alias_test`, `client_test`).
`computeCenters` is currently in an anonymous namespace inside `AtuPreTuneDialog.cpp` — either move it to a header (e.g. `AtuPreTuneCenters.h` next to the dialog) or expose it as a free function in the AetherSDR namespace.
Scope and risk
- New test only, no production code change.
- Lifts `computeCenters` out of the anonymous namespace into something testable — minor refactor.
Context
Surfaced during stale-code audit of #2630. Mechanical, small, well-scoped.
73, Jeremy KK7GWY & Claude (AI dev partner)
Background
The ATU pre-tune sweep landed in #2630 has a pure-math `computeCenters(double lowMhz, double highMhz, int segmentKhz) → QVector` helper in `AtuPreTuneDialog.cpp` that generates the per-band sweep points. The issue body for #2624 included an explicit reference table for IARU Region 1 (160m=23 points, 80m=34, 60m=2, 40m=8, 30m=2, 20m=7, 17m=2, 15m=6, 12m=2, 10m=23, 6m=20 — 129 total) which is exactly the kind of fixed-point oracle a small unit test should lock in.
The function isn't currently covered by any test. Adding one would:
Fix
Add `tests/atu_pretune_centers_test.cpp` with assertions like:
```cpp
// IARU R1 reference (from issue #2624)
expect(computeCenters(1.800, 2.000, 9).size() == 23, "160m IARU R1 → 23 points");
expect(qFuzzyCompare(computeCenters(1.800, 2.000, 9).first(), 1.8045), "160m first center 1804.5 kHz");
expect(computeCenters(14.000, 14.350, 51).size() == 7, "20m IARU R1 → 7 points");
// ... one row per band in the reference table
// Plus edge cases:
expect(computeCenters(5.3515, 5.3665, 9).size() == 2, "60m clamp last center");
expect(computeCenters(0.0, 0.0, 9).isEmpty(), "zero range returns empty");
expect(computeCenters(14.0, 14.001, 51).isEmpty(), "range smaller than segment returns empty");
```
Register the executable in `CMakeLists.txt` next to the other `test` harnesses (e.g. `antenna_alias_test`, `client_test`).
`computeCenters` is currently in an anonymous namespace inside `AtuPreTuneDialog.cpp` — either move it to a header (e.g. `AtuPreTuneCenters.h` next to the dialog) or expose it as a free function in the AetherSDR namespace.
Scope and risk
Context
Surfaced during stale-code audit of #2630. Mechanical, small, well-scoped.
73, Jeremy KK7GWY & Claude (AI dev partner)