defmodule Microwaveprop.Rover.AggregatorTest do
  use ExUnit.Case, async: true

  alias Microwaveprop.Rover.Aggregator

  describe "cell_margin_db/1" do
    test "empty list returns nil" do
      assert Aggregator.cell_margin_db([]) == nil
    end

    test "[10.0, 5.0, -2.0] returns 0.7*10 + 0.3*(13/3) ≈ 8.30" do
      assert_in_delta Aggregator.cell_margin_db([10.0, 5.0, -2.0]), 8.30, 0.01
    end

    test "[nil, 5.0] ignores nil and returns 5.0" do
      assert Aggregator.cell_margin_db([nil, 5.0]) == 5.0
    end

    test "all nils returns nil" do
      assert Aggregator.cell_margin_db([nil, nil]) == nil
    end
  end
end
