コード例 #1
0
ファイル: game_test.go プロジェクト: ujanssen/dorothea
// Each player has 4 game pieces, which are in the "out" area when the game starts
func TestGameOutAreaAtStart(t *testing.T) {
	g, _ := dorothea.NewGame(getNPlayerColors(4))
	for _, player := range g.Players {
		if player.PinsInOutArea() != 4 {
			t.Errorf("player.OutArea = %v, want 4", player.PinsInOutArea())
		}
	}
}
コード例 #2
0
ファイル: game_test.go プロジェクト: ujanssen/dorothea
// Test with valid n players
func testGameWithValidNPlayers(n, e int, t *testing.T) {
	g, err := dorothea.NewGame(getNPlayerColors(n))
	if err != nil {
		t.Errorf("dorothea.NewGame(%v), got error %v, want no error", n, g.Players, e)
	}
	if e != len(g.Players) {
		t.Errorf("dorothea.NewGame(%v) = %v, want %v", n, g.Players, e)
	}
}
コード例 #3
0
ファイル: game_test.go プロジェクト: ujanssen/dorothea
// At game start, all fields should be empty
func TestGameFieldsAtStart(t *testing.T) {
	playerColors := []dorothea.Color{dorothea.Red, dorothea.Green}
	g, _ := dorothea.NewGame(playerColors)

	for field := 0; field < 40; field++ {
		if g.GetColorOnField(field) != dorothea.Empty {
			t.Errorf("field = %v, want dorothea.Empty", field)

		}
	}
}
コード例 #4
0
ファイル: game_test.go プロジェクト: ujanssen/dorothea
// Start a Game with Red and Green.
// Red should be the first active player.
// Green should be the next player.
// Red should be the next player.
func TestGameFirstPlayerAtStart(t *testing.T) {
	playerColors := []dorothea.Color{dorothea.Red, dorothea.Green}
	g, _ := dorothea.NewGame(playerColors)

	c := g.CurrentPlayer().Color
	if c != dorothea.Red {
		t.Errorf("g.CurrentPlayer().Color = %v, want dorothea.Red", c)
	}

	e := g.NextPlayer().Color
	if e != dorothea.Green {
		t.Errorf("g.NextPlayer().Color = %v, want dorothea.Green", e)
	}

	r := g.NextPlayer().Color
	if r != dorothea.Red {
		t.Errorf("g.NextPlayer().Color = %v, want dorothea.Red", r)
	}
}
コード例 #5
0
ファイル: game_test.go プロジェクト: ujanssen/dorothea
func newGame() *dorothea.Game {
	g, _ := dorothea.NewGame([]dorothea.Color{dorothea.Red, dorothea.Green})
	return g
}
コード例 #6
0
ファイル: game_test.go プロジェクト: ujanssen/dorothea
// Test with invalid n players
func testGameWithInvalidNPlayers(n int, t *testing.T) {
	g, err := dorothea.NewGame(getNPlayerColors(n))
	if err == nil {
		t.Errorf("dorothea.NewGame(%v) = %v, want error", n, g.Players)
	}
}