package calc_test import ( "math" "testing" "galaxy/calc" ) func TestBlockUpgradeCost(t *testing.T) { cases := []struct { name string blockMass float64 currentTech float64 targetTech float64 want float64 }{ {"zero block mass returns zero", 0, 1.0, 2.0, 0}, {"target equal to current returns zero", 5, 2.0, 2.0, 0}, {"target below current returns zero", 5, 2.0, 1.0, 0}, {"doubling tech on mass 5 costs 25", 5, 1.0, 2.0, 25}, {"doubling tech on mass 10 costs 50", 10, 1.0, 2.0, 50}, {"partial step from 2.0 to 2.5 on mass 5", 5, 2.0, 2.5, 10}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { got := calc.BlockUpgradeCost(tc.blockMass, tc.currentTech, tc.targetTech) if math.Abs(got-tc.want) > 1e-9 { t.Errorf("BlockUpgradeCost(%v, %v, %v) = %v, want %v", tc.blockMass, tc.currentTech, tc.targetTech, got, tc.want) } }) } }