Beispiel #1
0
// 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())
		}
	}
}
Beispiel #2
0
// 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)
	}
}
Beispiel #3
0
// 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)

		}
	}
}
Beispiel #4
0
// 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)
	}
}
Beispiel #5
0
func newGame() *dorothea.Game {
	g, _ := dorothea.NewGame([]dorothea.Color{dorothea.Red, dorothea.Green})
	return g
}
Beispiel #6
0
// 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)
	}
}