test: player base report
This commit is contained in:
@@ -8,6 +8,49 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestReportRace(t *testing.T) {
|
||||
c, _ := newCache()
|
||||
|
||||
c.TurnCalculateVotes()
|
||||
|
||||
rep := c.InitReport(2)
|
||||
assert.Equal(t, 2, int(rep.Turn))
|
||||
|
||||
c.ReportRace(Race_0_idx, rep, nil, nil)
|
||||
|
||||
assert.Equal(t, Race_0.Name, rep.Race)
|
||||
assert.Equal(t, Race_0.ID, rep.RaceID)
|
||||
assert.Equal(t, 0.1, float64(rep.Votes))
|
||||
|
||||
for i := range rep.Player {
|
||||
p := &rep.Player[i]
|
||||
switch p.ID {
|
||||
case Race_0_ID:
|
||||
assert.Equal(t, Race_0.Name, p.Name)
|
||||
assert.Equal(t, 1.1, float64(p.Drive))
|
||||
assert.Equal(t, 1.2, float64(p.Weapons))
|
||||
assert.Equal(t, 1.3, float64(p.Shields))
|
||||
assert.Equal(t, 1.4, float64(p.Cargo))
|
||||
assert.Equal(t, 100., float64(p.Population))
|
||||
assert.Equal(t, 100., float64(p.Industry))
|
||||
assert.Equal(t, 2, int(p.Planets))
|
||||
assert.Equal(t, 0.1, float64(p.Votes))
|
||||
assert.Equal(t, "-", p.Relation)
|
||||
case Race_1_ID:
|
||||
assert.Equal(t, Race_1.Name, p.Name)
|
||||
assert.Equal(t, 2.1, float64(p.Drive))
|
||||
assert.Equal(t, 2.2, float64(p.Weapons))
|
||||
assert.Equal(t, 2.3, float64(p.Shields))
|
||||
assert.Equal(t, 2.4, float64(p.Cargo))
|
||||
assert.Equal(t, 0., float64(p.Population))
|
||||
assert.Equal(t, 0., float64(p.Industry))
|
||||
assert.Equal(t, 1, int(p.Planets))
|
||||
assert.Equal(t, 0., float64(p.Votes))
|
||||
assert.Equal(t, "War", p.Relation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportLocalShipClass(t *testing.T) {
|
||||
c, _ := newCache()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user