aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/minbet_regression_test.go
blob: 578c251a3f7264a8d0ccb8a5042ab1cdce59e3a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package casino

import "testing"

// TestMinBetAboveDefaultMaxRejected guards the config/validate + Normalize
// interaction: an unset max_bet defaults to DefaultMaxBet, so a larger min_bet
// must be rejected (and Normalize must never leave MaxBet below MinBet), or the
// game would accept a table every wager is rejected from.
func TestMinBetAboveDefaultMaxRejected(t *testing.T) {
	if err := (TableConfig{ID: "bj", Game: GameBlackjack, MinBet: DefaultMaxBet + 1}).Validate(); err == nil {
		t.Fatal("table accepted min_bet above the default max")
	}
	if err := (MachineConfig{ID: "slots", Game: GameSlots, MinBet: DefaultMaxBet + 1}).Validate(); err == nil {
		t.Fatal("machine accepted min_bet above the default max")
	}

	m := MachineConfig{ID: "slots", Game: GameSlots, MinBet: DefaultMaxBet + 5}.Normalize()
	if m.MaxBet < m.MinBet {
		t.Fatalf("normalized machine left max %d below min %d", m.MaxBet, m.MinBet)
	}
	tc := TableConfig{ID: "bj", Game: GameBlackjack, MinBet: DefaultMaxBet + 5}.Normalize()
	if tc.MaxBet < tc.MinBet {
		t.Fatalf("normalized table left max %d below min %d", tc.MaxBet, tc.MinBet)
	}
}