tests: produce on planets, unload on routes
This commit is contained in:
@@ -14,7 +14,7 @@ func TestPlanetProduction(t *testing.T) {
|
||||
assert.Equal(t, 250., game.PlanetProduction(0., 1000.))
|
||||
}
|
||||
|
||||
func TestIncreaseIndustry(t *testing.T) {
|
||||
func TestProduceIndustry(t *testing.T) {
|
||||
HW := &game.Planet{
|
||||
PlanetReport: game.PlanetReport{
|
||||
UninhabitedPlanet: game.UninhabitedPlanet{
|
||||
@@ -35,23 +35,141 @@ func TestIncreaseIndustry(t *testing.T) {
|
||||
Industry: 500,
|
||||
},
|
||||
}
|
||||
HW.IncreaseIndustry()
|
||||
HW.ProduceIndustry()
|
||||
assert.InDelta(t, 196.078, HW.Capital, 0.0005)
|
||||
|
||||
HW.Capital = 0
|
||||
HW.Material = 200
|
||||
|
||||
HW.IncreaseIndustry()
|
||||
HW.ProduceIndustry()
|
||||
assert.Equal(t, 200., HW.Capital)
|
||||
assert.Equal(t, 0., HW.Material)
|
||||
|
||||
DW.IncreaseIndustry()
|
||||
DW.ProduceIndustry()
|
||||
assert.InDelta(t, 98.039, DW.Capital, 0.0003)
|
||||
|
||||
DW.Capital = 0
|
||||
DW.Material = 100
|
||||
|
||||
DW.IncreaseIndustry()
|
||||
DW.ProduceIndustry()
|
||||
assert.Equal(t, 100., DW.Capital)
|
||||
assert.Equal(t, 0., DW.Material)
|
||||
}
|
||||
|
||||
func TestProduceMaterial(t *testing.T) {
|
||||
HW := &game.Planet{
|
||||
PlanetReport: game.PlanetReport{
|
||||
UninhabitedPlanet: game.UninhabitedPlanet{
|
||||
Size: 1000,
|
||||
Resources: 10,
|
||||
},
|
||||
Population: 1000,
|
||||
Industry: 1000,
|
||||
},
|
||||
}
|
||||
assert.Equal(t, 0., HW.Material)
|
||||
|
||||
HW.ProduceMaterial()
|
||||
assert.Equal(t, 10000., HW.Material)
|
||||
|
||||
HW.Industry = 500
|
||||
HW.Population = 500
|
||||
HW.ProduceMaterial()
|
||||
assert.Equal(t, 15000., HW.Material)
|
||||
|
||||
HW.Population = 1000
|
||||
HW.ProduceMaterial()
|
||||
assert.Equal(t, 21250., HW.Material)
|
||||
}
|
||||
|
||||
func TestUnpackCapital(t *testing.T) {
|
||||
HW := &game.Planet{
|
||||
PlanetReport: game.PlanetReport{
|
||||
UninhabitedPlanet: game.UninhabitedPlanet{
|
||||
Size: 1000,
|
||||
Resources: 10,
|
||||
},
|
||||
Population: 1000,
|
||||
Industry: 1000,
|
||||
},
|
||||
}
|
||||
assert.Equal(t, 0., HW.Capital)
|
||||
|
||||
HW.UnpackCapital()
|
||||
assert.Equal(t, 1000., HW.Industry)
|
||||
assert.Equal(t, 0., HW.Capital)
|
||||
|
||||
HW.Capital = 123.
|
||||
HW.UnpackCapital()
|
||||
assert.Equal(t, 1000., HW.Industry)
|
||||
assert.Equal(t, 123., HW.Capital)
|
||||
|
||||
HW.Industry = 987.
|
||||
HW.UnpackCapital()
|
||||
assert.Equal(t, 1000., HW.Industry)
|
||||
assert.Equal(t, 110., HW.Capital)
|
||||
|
||||
HW.Population = 876.
|
||||
HW.Industry = 800.
|
||||
HW.UnpackCapital()
|
||||
assert.Equal(t, 876., HW.Population)
|
||||
assert.Equal(t, 876., HW.Industry)
|
||||
assert.Equal(t, 34., HW.Capital)
|
||||
}
|
||||
|
||||
func TestUnpackColonists(t *testing.T) {
|
||||
HW := &game.Planet{
|
||||
PlanetReport: game.PlanetReport{
|
||||
UninhabitedPlanet: game.UninhabitedPlanet{
|
||||
Size: 1000,
|
||||
Resources: 10,
|
||||
},
|
||||
Population: 1000,
|
||||
Industry: 1000,
|
||||
},
|
||||
}
|
||||
assert.Equal(t, 0., HW.Colonists)
|
||||
|
||||
HW.UnpackColonists()
|
||||
assert.Equal(t, 1000., HW.Population)
|
||||
assert.Equal(t, 0., HW.Colonists)
|
||||
|
||||
HW.Colonists = 1.05
|
||||
HW.UnpackColonists()
|
||||
assert.Equal(t, 1000., HW.Population)
|
||||
assert.Equal(t, 1.05, HW.Colonists)
|
||||
|
||||
HW.Population = 996.0
|
||||
HW.UnpackColonists()
|
||||
assert.Equal(t, 1000., HW.Population)
|
||||
assert.Equal(t, 0.55, HW.Colonists)
|
||||
|
||||
HW.Population = 0.0
|
||||
HW.UnpackColonists()
|
||||
assert.Equal(t, 4.4, HW.Population)
|
||||
assert.Equal(t, 0., HW.Colonists)
|
||||
}
|
||||
|
||||
func TestProducePopulation(t *testing.T) {
|
||||
HW := &game.Planet{
|
||||
PlanetReport: game.PlanetReport{
|
||||
UninhabitedPlanet: game.UninhabitedPlanet{
|
||||
Size: 1000,
|
||||
Resources: 10,
|
||||
},
|
||||
Population: 500,
|
||||
Industry: 1000,
|
||||
},
|
||||
}
|
||||
assert.Equal(t, 500., HW.Population)
|
||||
assert.Equal(t, 0., HW.Colonists)
|
||||
|
||||
HW.ProducePopulation()
|
||||
assert.Equal(t, 540., HW.Population)
|
||||
assert.Equal(t, 0., HW.Colonists)
|
||||
|
||||
HW.Population = 1000.
|
||||
HW.ProducePopulation()
|
||||
assert.Equal(t, 1000., HW.Population)
|
||||
assert.Equal(t, 10., HW.Colonists)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user