code cleanup

This commit is contained in:
Ilia Denisov
2025-09-25 21:53:16 +03:00
parent 46066d890b
commit 6d87ea6086
8 changed files with 49 additions and 294 deletions
+7 -20
View File
@@ -3,7 +3,8 @@ package game_test
import (
"testing"
"github.com/iliadenisov/galaxy/pkg/game"
"github.com/iliadenisov/galaxy/pkg/model/game"
"github.com/stretchr/testify/assert"
)
func Test_ShipType(t *testing.T) {
@@ -14,10 +15,7 @@ func Test_ShipType(t *testing.T) {
Shields: 4,
Cargo: 0,
}
if Gunship.EmptyMass() != 11. {
t.Errorf("Cruiser mass expected %.3f but %.3f given", 11., Gunship.EmptyMass())
}
assert.Equal(t, Gunship.EmptyMass(), 11.)
Cruiser := game.ShipType{
Drive: 15,
@@ -26,10 +24,7 @@ func Test_ShipType(t *testing.T) {
Shields: 15,
Cargo: 0,
}
if Cruiser.EmptyMass() != 45. {
t.Errorf("Cruiser mass expected %.3f but %.3f given", 45., Cruiser.EmptyMass())
}
assert.Equal(t, Cruiser.EmptyMass(), 45.)
sg := game.ShipGroup{
Type: Cruiser,
@@ -40,15 +35,11 @@ func Test_ShipType(t *testing.T) {
Shields: 1.0,
Cargo: 1.0,
}
upgradeCost := sg.UpgradeDriveCost(2.0) +
sg.UpgradeWeaponsCost(2.0) +
sg.UpgradeShieldsCost(2.0) +
sg.UpgradeCargoCost(2.0)
if upgradeCost != 225. {
t.Errorf("Cruiser upgrade cost expected %.3f but %.3f given", 225., upgradeCost)
}
assert.Equal(t, upgradeCost, 225.)
}
func Test_CargoCapacity(t *testing.T) {
@@ -69,9 +60,7 @@ func Test_CargoCapacity(t *testing.T) {
Shields: 1.0,
Cargo: 1.0,
}
if sg.CargoCapacity() != expectCapacity {
t.Errorf("expected CargoCapacity=%.3f but %.3f given", expectCapacity, sg.CargoCapacity())
}
assert.Equal(t, expectCapacity, sg.CargoCapacity())
}
test(1, 1.05)
test(5, 6.25)
@@ -99,7 +88,5 @@ func Test_BombingPower(t *testing.T) {
}
expectedBombingPower := 139.295
result := sg.BombingPower()
if result != expectedBombingPower {
t.Errorf("expected BombingPower=%.3f but %.3f given", expectedBombingPower, result)
}
assert.Equal(t, expectedBombingPower, result)
}