func TestTableCreation(t *testing.T) { s1 := noLieStrategy.New() s2 := noLieStrategy.New() s3 := noLieStrategy.New() strategies := make([]strategy.Interface, 3) strategies[0] = s1 strategies[1] = s2 strategies[2] = s3 names := make([]string, 3) names[0] = "a" names[1] = "b" names[2] = "c" table := New(strategies, names) if !(table.players[0].DeckSize() == 2) { t.Errorf("Player deck size wrong: expected %d, got %d", 2, table.players[0].DeckSize()) } if !(table.players[2].DeckSize() == 2) { t.Errorf("Player deck size wrong: expected %d, got %d", 2, table.players[2].DeckSize()) } if !(table.centerDeck.Size() == 9) { t.Errorf("Center deck size wrong: expected %d, got %d", 9, table.centerDeck.Size()) } fmt.Println(table.PlayerCoins()["noLieStr"]) }
func TestPlayerCreation(t *testing.T) { strategy := noLieStrategy.New() centerDeck := deck.NewRandomCenter() playerDeck := deck.New(centerDeck.TakeCards(2)) player := New("p1", strategy, playerDeck, 2) if !(player.Name() == "p1") { t.Errorf("Table name wrong: expected %q, got %q", "p1", player.Name()) } }
func createStrategyByName(name string) strategy.Interface { switch name { case "noLie": noLieStrategy := noLieStrategy.New() return noLieStrategy case "thief": thiefStrategy := thiefStrategy.New() return thiefStrategy case "console": consoleStrategy := consoleStrategy.New() return consoleStrategy case "random": randomStrategy := randomStrategy.New() return randomStrategy } return nil }
func TestStrategyInterface(t *testing.T) { noLieStrategy := noLieStrategy.New() testInterface(noLieStrategy) }