refactor: floats, tests
This commit is contained in:
@@ -17,15 +17,15 @@ func TestCargoCapacity(t *testing.T) {
|
||||
Armament: 1,
|
||||
Weapons: 1,
|
||||
Shields: 1,
|
||||
Cargo: cargoSize,
|
||||
Cargo: game.F(cargoSize),
|
||||
}
|
||||
sg := game.ShipGroup{
|
||||
Number: 1,
|
||||
Tech: map[game.Tech]float64{
|
||||
game.TechDrive: 1.5,
|
||||
game.TechWeapons: 1.1,
|
||||
game.TechShields: 2.0,
|
||||
game.TechCargo: 1.0,
|
||||
Tech: map[game.Tech]game.Float{
|
||||
game.TechDrive: game.F(1.5),
|
||||
game.TechWeapons: game.F(1.1),
|
||||
game.TechShields: game.F(2.0),
|
||||
game.TechCargo: game.F(1.0),
|
||||
},
|
||||
}
|
||||
assert.Equal(t, expectCapacity, sg.CargoCapacity(&ship))
|
||||
@@ -48,11 +48,11 @@ func TestCarryingAndFullMass(t *testing.T) {
|
||||
}
|
||||
sg := &game.ShipGroup{
|
||||
Number: 1,
|
||||
Tech: map[game.Tech]float64{
|
||||
game.TechDrive: 1.0,
|
||||
game.TechWeapons: 1.0,
|
||||
game.TechShields: 1.0,
|
||||
game.TechCargo: 1.0,
|
||||
Tech: map[game.Tech]game.Float{
|
||||
game.TechDrive: game.F(1.0),
|
||||
game.TechWeapons: game.F(1.0),
|
||||
game.TechShields: game.F(1.0),
|
||||
game.TechCargo: game.F(1.0),
|
||||
},
|
||||
Load: 0.0,
|
||||
}
|
||||
@@ -80,11 +80,11 @@ func TestSpeed(t *testing.T) {
|
||||
}
|
||||
sg := &game.ShipGroup{
|
||||
Number: 1,
|
||||
Tech: map[game.Tech]float64{
|
||||
game.TechDrive: 1.0,
|
||||
game.TechWeapons: 1.0,
|
||||
game.TechShields: 1.0,
|
||||
game.TechCargo: 1.0,
|
||||
Tech: map[game.Tech]game.Float{
|
||||
game.TechDrive: game.F(1.0),
|
||||
game.TechWeapons: game.F(1.0),
|
||||
game.TechShields: game.F(1.0),
|
||||
game.TechCargo: game.F(1.0),
|
||||
},
|
||||
Load: 0.0,
|
||||
}
|
||||
@@ -109,11 +109,11 @@ func TestBombingPower(t *testing.T) {
|
||||
}
|
||||
sg := game.ShipGroup{
|
||||
Number: 1,
|
||||
Tech: map[game.Tech]float64{
|
||||
game.TechDrive: 1.0,
|
||||
game.TechWeapons: 1.0,
|
||||
game.TechShields: 1.0,
|
||||
game.TechCargo: 1.0,
|
||||
Tech: map[game.Tech]game.Float{
|
||||
game.TechDrive: game.F(1.0),
|
||||
game.TechWeapons: game.F(1.0),
|
||||
game.TechShields: game.F(1.0),
|
||||
game.TechCargo: game.F(1.0),
|
||||
},
|
||||
}
|
||||
assert.Equal(t, 139.295, number.Fixed3(sg.BombingPower(&BattleStation)))
|
||||
@@ -123,9 +123,9 @@ func TestBombingPower(t *testing.T) {
|
||||
|
||||
func TestDriveEffective(t *testing.T) {
|
||||
tc := []struct {
|
||||
driveShipType float64
|
||||
driveTech float64
|
||||
expectDriveEffective float64
|
||||
driveShipType game.Float
|
||||
driveTech game.Float
|
||||
expectDriveEffective game.Float
|
||||
}{
|
||||
{1, 1, 1},
|
||||
{1, 2, 2},
|
||||
@@ -139,20 +139,20 @@ func TestDriveEffective(t *testing.T) {
|
||||
someShip := game.ShipType{
|
||||
Drive: tc[i].driveShipType,
|
||||
Armament: rand.UintN(30) + 1,
|
||||
Weapons: rand.Float64()*30 + 1,
|
||||
Shields: rand.Float64()*100 + 1,
|
||||
Cargo: rand.Float64()*20 + 1,
|
||||
Weapons: game.F(rand.Float64()*30 + 1),
|
||||
Shields: game.F(rand.Float64()*100 + 1),
|
||||
Cargo: game.F(rand.Float64()*20 + 1),
|
||||
}
|
||||
sg := game.ShipGroup{
|
||||
Number: rand.UintN(4) + 1,
|
||||
Tech: map[game.Tech]float64{
|
||||
Tech: map[game.Tech]game.Float{
|
||||
game.TechDrive: tc[i].driveTech,
|
||||
game.TechWeapons: rand.Float64()*5 + 1,
|
||||
game.TechShields: rand.Float64()*5 + 1,
|
||||
game.TechCargo: rand.Float64()*5 + 1,
|
||||
game.TechWeapons: game.F(rand.Float64()*5 + 1),
|
||||
game.TechShields: game.F(rand.Float64()*5 + 1),
|
||||
game.TechCargo: game.F(rand.Float64()*5 + 1),
|
||||
},
|
||||
}
|
||||
assert.Equal(t, tc[i].expectDriveEffective, sg.DriveEffective(&someShip))
|
||||
assert.Equal(t, tc[i].expectDriveEffective.F(), sg.DriveEffective(&someShip))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ func TestShipGroupEqual(t *testing.T) {
|
||||
FleetID: &fleetId,
|
||||
CargoType: &mat,
|
||||
Load: 123.45,
|
||||
Tech: map[game.Tech]float64{
|
||||
Tech: map[game.Tech]game.Float{
|
||||
game.TechDrive: 1.0,
|
||||
game.TechWeapons: 1.0,
|
||||
game.TechShields: 1.0,
|
||||
|
||||
Reference in New Issue
Block a user