prop/test/microwaveprop/rover/link_margin_test.exs
Graham McIntire 9ef10f5aae
test: expand coverage across rover, pskr, valkey, skewt, scores
- Rover.Compute: road/prominence/clearance/clutter/canopy tests (90%)
- Rover.Prominence: full unit test suite with mock elev_lookup (100%)
- Rover.Elevation: dedup + multi-tile tests (44%)
- Rover.LinkMargin: edge cases, negative scores, all modes (57%)
- Rover.Location: changeset validation + statuses/0 (100%)
- RoverPlanning.Path: changeset validation + statuses/0 (67%)
- Pskr.FeatureBin: changeset validation (100%)
- Pskr.Mqtt: QoS reject, unknown type, varint overflow, ping/disconnect (97%)
- Valkey: not-configured error paths, empty guards (55%)
- ScoresController: bad params, time format, missing band tests (81%)
- SkewtLive: info/no-profiles state, loading states (29%)
2026-05-07 12:51:58 -05:00

62 lines
1.6 KiB
Elixir

defmodule Microwaveprop.Rover.LinkMarginTest do
use ExUnit.Case, async: true
alias Microwaveprop.Rover.LinkMargin
describe "score_to_db/1" do
test "0 maps to -25.0 dB" do
assert LinkMargin.score_to_db(0) == -25.0
end
test "50 maps to 0.0 dB" do
assert LinkMargin.score_to_db(50) == 0.0
end
test "100 maps to 25.0 dB" do
assert LinkMargin.score_to_db(100) == 25.0
end
test "nil maps to nil" do
assert LinkMargin.score_to_db(nil) == nil
end
test "negative score maps below -25 dB" do
assert LinkMargin.score_to_db(-10) == -30.0
end
test "score above 100 maps above 25 dB" do
assert LinkMargin.score_to_db(120) == 35.0
end
end
describe "link_margin_from_score/2" do
test "score 80 in :ssb mode = 15.0 dB" do
assert LinkMargin.link_margin_from_score(80, :ssb) == 15.0
end
test "score 50 in :cw mode = 18.0 dB (0 - (-18))" do
assert LinkMargin.link_margin_from_score(50, :cw) == 18.0
end
test "nil score returns nil" do
assert LinkMargin.link_margin_from_score(nil, :ssb) == nil
end
test "score 0 in :cw mode = -7.0 dB" do
assert LinkMargin.link_margin_from_score(0, :cw) == -7.0
end
test "score 100 in :cw mode = 43.0 dB" do
assert LinkMargin.link_margin_from_score(100, :cw) == 43.0
end
test "score 30 in :ssb mode gives negative margin" do
margin = LinkMargin.link_margin_from_score(30, :ssb)
assert margin < 0
end
test "score 50 in :q65_60a mode = 24.0 dB" do
assert LinkMargin.link_margin_from_score(50, :q65_60a) == 24.0
end
end
end