Skip to content

Unit tests for license-class-filtered contiguousRegionsForBand (follow-up to #2649) #3060

Description

@ten9876

Background

PR #3050 (closes #2649) added a license-class-aware overload of `BandPlanManager::contiguousRegionsForBand` that filters segments by the operator's class before merging contiguous regions.

The filter-before-merge ordering is subtle and load-bearing: if an allowed segment is adjacent to a disallowed one, they must NOT merge — otherwise the merged region's center could fall on a disallowed frequency. The comment in `BandPlanManager.cpp:91` calls this out, but there's currently no test that pins the invariant.

A future refactor (e.g. consolidating segment iteration, switching to STL algorithms, parallelising the loop) could silently break this without anyone noticing until an operator hits a sub-band their licence class doesn't authorize.

Proposed test

Add a new `tests/band_plan_license_filter_test.cpp` with at least:

  1. Empty class → no filter — three-arg overload with `""` returns the same regions as the two-arg overload.
  2. Empty-license segments always pass — a BCN-marker segment with `"license": ""` is included for any `allowedClass`.
  3. Class filter drops non-matching segments — given segments `[A: "E"], [B: "G"], [C: "E,G"]`, filtering by `"T"` returns nothing; filtering by `"G"` returns B + C.
  4. Adjacent allowed/disallowed segments stay separate — segments `[3.500–3.510 "E"], [3.510–3.570 "E,G"]` filtered by `"G"` returns exactly one region `[3.510–3.570]` (not the merged `[3.500–3.570]`).
  5. Class filter is case-sensitive and exact — `"G "` (with trailing space) is whitespace-trimmed before comparison; `"GE"` doesn't match `"G,E"` field.

Effort

~150 LOC for the test file. Run via `add_executable` + `add_test` in `CMakeLists.txt`, same pattern as `profile_transfer_test`, `band_plan_test`, etc.

Eligibility

`aetherclaude-eligible` — well-bounded test addition, no behavioural change.

Spotted by

Review of PR #3050 — the filter-before-merge invariant is the kind of correctness property that begs for a test before any future refactoring lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement to existing featuregood first issueGood for newcomersmaintainer-reviewRequires maintainer review before any action is taken

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions