setup() { load '../../package/kit-busrouter/files/usr/lib/busrouter/lib-score.sh'; } @test "composite weights sum to a 0-100 score" { # latency35 dl25 up10 jit10 loss10 sig10 ; all metrics perfect -> 100 run score_composite 5 25 12.5 1 0 -65 [ "$output" -eq 100 ] } @test "composite all-worst -> 0" { run score_composite 200 0.5 0.5 50 40 -95 [ "$output" -eq 0 ] } @test "rolling average of 3 samples" { run rolling_avg 90 60 30 # -> 60 [ "$output" -eq 60 ] } @test "rolling average rounds half-up" { run rolling_avg 100 100 99 # 299/3 = 99.67 -> 100 [ "$output" -eq 100 ] } @test "signal weight redistributes when no modem (signal='')" { run score_composite 5 25 12.5 1 0 "" # still 100, sig weight moved to latency/throughput [ "$output" -eq 100 ] }