33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package baishun
|
|
|
|
import "testing"
|
|
|
|
func TestGameListRowGameModeAlwaysFixed(t *testing.T) {
|
|
testCases := []string{"", "[1]", "[2]", "[3]", "CHAT_ROOM"}
|
|
for _, raw := range testCases {
|
|
row := gameListRow{GameModeRaw: raw}
|
|
if got := row.gameMode(); got != baishunFixedGameMode {
|
|
t.Fatalf("gameMode() = %d, want %d for raw %q", got, baishunFixedGameMode, raw)
|
|
}
|
|
if got := row.toListItem().GameMode; got != baishunFixedGameMode {
|
|
t.Fatalf("toListItem().GameMode = %d, want %d for raw %q", got, baishunFixedGameMode, raw)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestAdminGameModeAlwaysFixed(t *testing.T) {
|
|
row := adminGameRow{
|
|
GameModeRaw: "[3]",
|
|
CatalogGameModeJSON: "[1]",
|
|
}
|
|
if got := row.toAdminItem().GameMode; got != baishunFixedGameMode {
|
|
t.Fatalf("toAdminItem().GameMode = %d, want %d", got, baishunFixedGameMode)
|
|
}
|
|
if got := formatAdminGameModeRaw(0); got != "[2]" {
|
|
t.Fatalf("formatAdminGameModeRaw(0) = %q, want [2]", got)
|
|
}
|
|
if got := formatAdminGameModeRaw(99); got != "[2]" {
|
|
t.Fatalf("formatAdminGameModeRaw(99) = %q, want [2]", got)
|
|
}
|
|
}
|