<commit_before>package player

import (
	"testing"

	"github.com/svera/acquire/interfaces"
	"github.com/svera/acquire/mocks"
)

func TestPickTile(t *testing.T) {
	player := New()
	tl := &mocks.Tile{FakeNumber: 2, FakeLetter: "C"}
	player.PickTile(tl)
	if len(player.tiles) != 1 {
		t.Errorf("Player must have exactly 1 tile, got %d", len(player.tiles))
	}
}

func TestUseTile(t *testing.T) {
	player := New()

	player.tiles = []interfaces.Tile{
		&mocks.Tile{FakeNumber: 7, FakeLetter: "c"},
		&mocks.Tile{FakeNumber: 5, FakeLetter: "A"},
		&mocks.Tile{FakeNumber: 8, FakeLetter: "E"},
		&mocks.Tile{FakeNumber: 3, FakeLetter: "D"},
		&mocks.Tile{FakeNumber: 1, FakeLetter: "B"},
		&mocks.Tile{FakeNumber: 4, FakeLetter: "I"},
	}

	tl := &mocks.Tile{FakeNumber: 5, FakeLetter: "A"}
	player.DiscardTile(tl)
	if len(player.tiles) != 5 {
		t.Errorf("Players must have 5 tiles after using one, got %d", len(player.tiles))
	}
	if tl.Number() != 5 || tl.Letter() != "A" {
		t.Errorf("DiscardTile() must return tile 5A")
	}
}

func TestShares(t *testing.T) {
	corp := &mocks.Corporation{}
	expected := 5
	player := &Player{
		shares: map[interfaces.Corporation]int{
			corp: expected,
		},
	}
	if player.Shares(corp) != expected {
		t.Errorf("Shares() must return that the player has exactly %d stock shares in corporation %p, got %d", expected, corp, player.Shares(corp))
	}
}

func TestAddShares(t *testing.T) {
	corp := &mocks.Corporation{}
	original := 5
	add := 2
	expected := 7
	player := &Player{
		shares: map[interfaces.Corporation]int{
			corp: original,
		},
	}
	player.AddShares(corp, add)
	if player.Shares(corp) != expected {
		t.Errorf("AddShares() must add %d stock shares as owned by the player in corporation %p, got %d", add, corp, player.Shares(corp))
	}
}<commit_msg>Added more player tests<commit_after>package player

import (
	"testing"

	"github.com/svera/acquire/interfaces"
	"github.com/svera/acquire/mocks"
)

func TestPickTile(t *testing.T) {
	player := New()
	tl := &mocks.Tile{FakeNumber: 2, FakeLetter: "C"}
	player.PickTile(tl)
	if len(player.tiles) != 1 {
		t.Errorf("Player must have exactly 1 tile, got %d", len(player.tiles))
	}
}

func TestUseTile(t *testing.T) {
	player := New()

	player.tiles = []interfaces.Tile{
		&mocks.Tile{FakeNumber: 7, FakeLetter: "c"},
		&mocks.Tile{FakeNumber: 5, FakeLetter: "A"},
		&mocks.Tile{FakeNumber: 8, FakeLetter: "E"},
		&mocks.Tile{FakeNumber: 3, FakeLetter: "D"},
		&mocks.Tile{FakeNumber: 1, FakeLetter: "B"},
		&mocks.Tile{FakeNumber: 4, FakeLetter: "I"},
	}

	tl := &mocks.Tile{FakeNumber: 5, FakeLetter: "A"}
	player.DiscardTile(tl)
	if len(player.tiles) != 5 {
		t.Errorf("Players must have 5 tiles after using one, got %d", len(player.tiles))
	}
	if tl.Number() != 5 || tl.Letter() != "A" {
		t.Errorf("DiscardTile() must return tile 5A")
	}
}

func TestShares(t *testing.T) {
	corp := &mocks.Corporation{}
	expected := 5
	player := &Player{
		shares: map[interfaces.Corporation]int{
			corp: expected,
		},
	}
	if player.Shares(corp) != expected {
		t.Errorf("Shares() must return that the player has exactly %d stock shares in corporation %p, got %d", expected, corp, player.Shares(corp))
	}
}

func TestAddShares(t *testing.T) {
	corp := &mocks.Corporation{}
	original := 5
	add := 2
	expected := 7
	player := &Player{
		shares: map[interfaces.Corporation]int{
			corp: original,
		},
	}
	player.AddShares(corp, add)
	if player.Shares(corp) != expected {
		t.Errorf("AddShares() must add %d stock shares as owned by the player in corporation %p, got %d", add, corp, player.Shares(corp))
	}
}

func TestRemoveShares(t *testing.T) {
	corp := &mocks.Corporation{}
	original := 5
	remove := 2
	expected := 3
	player := &Player{
		shares: map[interfaces.Corporation]int{
			corp: original,
		},
	}
	player.RemoveShares(corp, remove)
	if player.Shares(corp) != expected {
		t.Errorf("RemoveShares() must remove %d stock shares as owned by the player in corporation %p, got %d", remove, corp, player.Shares(corp))
	}
}

func TestTiles(t *testing.T) {
	player := &Player{
		tiles: []interfaces.Tile{
			&mocks.Tile{},
			&mocks.Tile{},
		},
	}
	if len(player.Tiles()) != 2 {
		t.Errorf("Tiles() must return 2 tiles in player's hand, got %d", len(player.Tiles()))
	}
}

func TestHasTile(t *testing.T) {
	player := &Player{
		tiles: []interfaces.Tile{
			&mocks.Tile{FakeNumber: 5, FakeLetter: "C"},
			&mocks.Tile{FakeNumber: 4, FakeLetter: "A"},
		},
	}
	if player.HasTile(&mocks.Tile{FakeNumber: 5, FakeLetter: "C"}) != true {
		t.Errorf("HasTile() must return true for tile 5C")
	}
	if player.HasTile(&mocks.Tile{FakeNumber: 2, FakeLetter: "F"}) != false {
		t.Errorf("HasTile() must return false for tile 2F")
	}

}
{'fraction_non_alphanumeric': 0.17203154977616714, 'fraction_numerical': 0.010019185674696228, 'mean_word_length': 4.319727891156463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6472672', 'n_tokens_mistral': 1984, 'n_tokens_neox': 1812, 'n_words': 440}