mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-14 07:12:03 +00:00
feat: add ranked season rollover policy
This commit is contained in:
@@ -8,7 +8,9 @@ func TestPartitionTeamsBalancesMeanRatingBeforeOpposingSpread(t *testing.T) {
|
||||
{PlayerID: "c", Rating: 1900}, {PlayerID: "d", Rating: 2000},
|
||||
}
|
||||
teams, err := PartitionTeams(players)
|
||||
if err != nil { t.Fatal(err) }
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if playerIDs(teams.Team0) != "a\x00d\x00" || playerIDs(teams.Team1) != "b\x00c\x00" {
|
||||
t.Fatalf("unexpected balanced partition: team0=%q team1=%q", playerIDs(teams.Team0), playerIDs(teams.Team1))
|
||||
}
|
||||
@@ -20,9 +22,13 @@ func TestPartitionTeamsIsIndependentOfInputOrder(t *testing.T) {
|
||||
{PlayerID: "c", Rating: 1500}, {PlayerID: "a", Rating: 1500},
|
||||
}
|
||||
first, err := PartitionTeams(players)
|
||||
if err != nil { t.Fatal(err) }
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
second, err := PartitionTeams([]Candidate{players[2], players[0], players[3], players[1]})
|
||||
if err != nil { t.Fatal(err) }
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if playerIDs(first.Team0) != playerIDs(second.Team0) || playerIDs(first.Team1) != playerIDs(second.Team1) {
|
||||
t.Fatalf("input order changed partition: first=%q/%q second=%q/%q", playerIDs(first.Team0), playerIDs(first.Team1), playerIDs(second.Team0), playerIDs(second.Team1))
|
||||
}
|
||||
@@ -31,6 +37,8 @@ func TestPartitionTeamsIsIndependentOfInputOrder(t *testing.T) {
|
||||
func TestPartitionTeamsRejectsUnsupportedShapes(t *testing.T) {
|
||||
for _, count := range []int{0, 1, 3, 7} {
|
||||
players := make([]Candidate, count)
|
||||
if _, err := PartitionTeams(players); err == nil { t.Fatalf("accepted %d players", count) }
|
||||
if _, err := PartitionTeams(players); err == nil {
|
||||
t.Fatalf("accepted %d players", count)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user