Skip to content

Commit

Permalink
Add tests that catch a few more edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Aug 26, 2023
1 parent e25418d commit 6d2da6f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
9 changes: 9 additions & 0 deletions test/fuzz_play.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ end
@test isempty(fuzz(;fun=play!,n_players=10, bank_roll=200, n_games=10_000))
end

@testset "Game: play! (3 Bot5050's)" begin
players = (
Player(Bot5050(), 1; bank_roll=9),
Player(Bot5050(), 2; bank_roll=5),
Player(Bot5050(), 3; bank_roll=4),
)
@test isempty(fuzz_given_players(;fun=play!, players, n_games=10_000))
end

@testset "Game: tournament! (2 Bot5050's)" begin
@test isempty(fuzz(;fun=tournament!,n_players=2, bank_roll=6, n_games=10_000))
@test isempty(fuzz(;fun=tournament!,n_players=2, bank_roll=30,n_games=100_000))
Expand Down
7 changes: 6 additions & 1 deletion test/fuzz_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ and if any fail, return the indices of
the games that fail. This is helpful
to enforce tests that work.
=#
function fuzz(;fun, n_players, n_games, bank_roll=200, chips=Int)
function fuzz(;fun, n_players, n_games, bank_roll=200)
Random.seed!(1234)
players = ntuple(i->Player(Bot5050(), i; bank_roll=bank_roll), n_players)
return fuzz_given_players(;fun, n_games, players)
end

function fuzz_given_players(;fun, n_games, players)
Random.seed!(1234)
games = map(x-> Game(deepcopy(players);logger=TexasHoldem.ByPassLogger()), 1:n_games)
crashes = Int[]
for n in 1:length(games)
Expand Down
2 changes: 1 addition & 1 deletion test/recreate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sort_cards(cards) =

@testset "Recreate game" begin
players = TH.Players(ntuple(i->Player(BotCheckCall(), i), 3))
game = Game(players)
game = Game(players; logger=TH.ByPassLogger())
TH.deal!(game.table, TH.blinds(game.table))
player = players[1]
rgame = TH.recreate_game(game, player)
Expand Down

0 comments on commit 6d2da6f

Please sign in to comment.