package calc_test

import (
	"testing"

	source "galaxy/calc"
	bridge "galaxy/core/calc"

	"github.com/stretchr/testify/assert"
)

func TestShipBuildCostParity(t *testing.T) {
	t.Parallel()
	cases := []struct {
		name                          string
		shipMass, material, resources float64
	}{
		{"material_covers_mass", 5, 10, 0.5},
		{"material_short", 10, 3, 0.5},
		{"no_material", 4, 0, 0.5},
		{"zero_resources_guard", 10, 3, 0},
	}
	for _, c := range cases {
		t.Run(c.name, func(t *testing.T) {
			t.Parallel()
			want := source.ShipBuildCost(c.shipMass, c.material, c.resources)
			got := bridge.ShipBuildCost(c.shipMass, c.material, c.resources)
			assert.Equal(t, want, got)
		})
	}
}

func TestProduceShipsInTurnParity(t *testing.T) {
	t.Parallel()
	cases := []struct {
		name                                               string
		productionAvailable, material, resources, shipMass float64
	}{
		{"ample_material", 100, 100, 10, 1},
		{"farmed_partial", 114, 0, 0.5, 10},
		{"no_production", 0, 50, 10, 5},
		{"zero_ship_mass", 100, 50, 10, 0},
	}
	for _, c := range cases {
		t.Run(c.name, func(t *testing.T) {
			t.Parallel()
			wantShips, wantMat, wantUsed, wantProg := source.ProduceShipsInTurn(
				c.productionAvailable, c.material, c.resources, c.shipMass)
			gotShips, gotMat, gotUsed, gotProg := bridge.ProduceShipsInTurn(
				c.productionAvailable, c.material, c.resources, c.shipMass)
			assert.Equal(t, wantShips, gotShips)
			assert.Equal(t, wantMat, gotMat)
			assert.Equal(t, wantUsed, gotUsed)
			assert.Equal(t, wantProg, gotProg)
		})
	}
}
