58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package game_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/iliadenisov/galaxy/internal/model/game"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPlanetProduction(t *testing.T) {
|
|
assert.Equal(t, 1000., game.PlanetProduction(1000., 1000.))
|
|
assert.Equal(t, 625., game.PlanetProduction(500., 1000.))
|
|
assert.Equal(t, 750., game.PlanetProduction(1000., 0.))
|
|
assert.Equal(t, 250., game.PlanetProduction(0., 1000.))
|
|
}
|
|
|
|
func TestIncreaseIndustry(t *testing.T) {
|
|
HW := &game.Planet{
|
|
PlanetReport: game.PlanetReport{
|
|
UninhabitedPlanet: game.UninhabitedPlanet{
|
|
Size: 1000,
|
|
Resources: 10,
|
|
},
|
|
Population: 1000,
|
|
Industry: 1000,
|
|
},
|
|
}
|
|
DW := &game.Planet{
|
|
PlanetReport: game.PlanetReport{
|
|
UninhabitedPlanet: game.UninhabitedPlanet{
|
|
Size: 500,
|
|
Resources: 10,
|
|
},
|
|
Population: 500,
|
|
Industry: 500,
|
|
},
|
|
}
|
|
HW.IncreaseIndustry()
|
|
assert.InDelta(t, 196.078, HW.Capital, 0.0005)
|
|
|
|
HW.Capital = 0
|
|
HW.Material = 200
|
|
|
|
HW.IncreaseIndustry()
|
|
assert.Equal(t, 200., HW.Capital)
|
|
assert.Equal(t, 0., HW.Material)
|
|
|
|
DW.IncreaseIndustry()
|
|
assert.InDelta(t, 98.039, DW.Capital, 0.0003)
|
|
|
|
DW.Capital = 0
|
|
DW.Material = 100
|
|
|
|
DW.IncreaseIndustry()
|
|
assert.Equal(t, 100., DW.Capital)
|
|
assert.Equal(t, 0., DW.Material)
|
|
}
|