<commit_before>package blackjack

import (
	"github.com/jkomoros/boardgame"
	"github.com/jkomoros/boardgame/playingcards"
	"github.com/jkomoros/boardgame/storage/memory"
	"testing"
)

func TestHandValue(t *testing.T) {

	manager := NewManager(memory.NewStorageManager())

	chest := manager.Chest()

	deck := chest.Deck("cards")

	tests := []struct {
		state    *playerState
		expected int
	}{
		{
			&playerState{
				Hand: createHand(deck, playingcards.Rank2, playingcards.Rank3, playingcards.Rank4),
			},
			9,
		},
		{
			&playerState{
				Hand: createHand(deck, playingcards.RankAce),
			},
			11,
		},
		{
			&playerState{
				Hand: createHand(deck, playingcards.RankAce, playingcards.RankAce),
			},
			12,
		},
		{
			&playerState{
				Hand: createHand(deck, playingcards.RankJack, playingcards.RankKing, playingcards.RankAce),
			},
			21,
		},
	}

	for i, test := range tests {
		result := test.state.HandValue()

		if result != test.expected {
			t.Error("Test", i, "Failed. Got", result, "wanted", test.expected)
		}
	}
}

func createHand(deck *boardgame.Deck, ranks ...playingcards.Rank) *boardgame.GrowableStack {
	result := boardgame.NewGrowableStack(deck, 0)

	givenCards := make(map[int]bool)

	for i, rank := range ranks {
		for i, c := range deck.Components() {

			//Skip cards we have already used
			if givenCards[i] {
				continue
			}

			card := c.Values.(*playingcards.Card)
<commit_msg>Fixed failing test in last commit.<commit_after>package blackjack

import (
	"github.com/jkomoros/boardgame"
	"github.com/jkomoros/boardgame/playingcards"
	"github.com/jkomoros/boardgame/storage/memory"
	"testing"
)

func TestHandValue(t *testing.T) {

	manager := NewManager(memory.NewStorageManager())

	chest := manager.Chest()

	deck := chest.Deck("cards")

	tests := []struct {
		state    *playerState
		expected int
	}{
		{
			&playerState{
				VisibleHand: createHand(deck, playingcards.Rank2, playingcards.Rank3, playingcards.Rank4),
				HiddenHand:  boardgame.NewGrowableStack(deck, 0),
			},
			9,
		},
		{
			&playerState{
				VisibleHand: createHand(deck, playingcards.RankAce),
				HiddenHand:  boardgame.NewGrowableStack(deck, 0),
			},
			11,
		},
		{
			&playerState{
				VisibleHand: createHand(deck, playingcards.RankAce, playingcards.RankAce),
				HiddenHand:  boardgame.NewGrowableStack(deck, 0),
			},
			12,
		},
		{
			&playerState{
				VisibleHand: createHand(deck, playingcards.RankJack, playingcards.RankKing, playingcards.RankAce),
				HiddenHand:  boardgame.NewGrowableStack(deck, 0),
			},
			21,
		},
	}

	for i, test := range tests {
		result := test.state.HandValue()

		if result != test.expected {
			t.Error("Test", i, "Failed. Got", result, "wanted", test.expected)
		}
	}
}

func createHand(deck *boardgame.Deck, ranks ...playingcards.Rank) *boardgame.GrowableStack {
	result := boardgame.NewGrowableStack(deck, 0)

	givenCards := make(map[int]bool)

	for i, rank := range ranks {
		for i, c := range deck.Components() {

			//Skip cards we have already used
			if givenCards[i] {
				continue
			}

			card := c.Values.(*playingcards.Card)

{'fraction_non_alphanumeric': 0.14137819475897767, 'fraction_numerical': 0.008411517308314461, 'mean_word_length': 3.663650075414781, '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': '3691331', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1089, 'n_words': 209}