package casino import "testing" func TestCalculateRTPUsesLongestWayOnly(t *testing.T) { profile := SlotProfile{ Rows: 3, Reels: 5, Ways: 243, Symbols: []SlotSymbol{{ID: "x", Weight: 1, Payout: map[int]float64{3: 1, 4: 2, 5: 3}}}, FreeSpinTrigger: "scatter", FreeSpinCount: 8, } if got := CalculateRTP(profile); got != 3 { t.Fatalf("RTP = %v, want 3", got) } } func TestValidateRTP(t *testing.T) { profile := SlotProfile{Rows: 3, Reels: 5, Ways: 243, TargetRTP: 3, Symbols: []SlotSymbol{{ID: "x", Weight: 1, Payout: map[int]float64{5: 3}}}} if err := ValidateRTP(profile, 0.000001); err != nil { t.Fatal(err) } } func TestScaleToRTP(t *testing.T) { profile := ScaleToRTP(DefaultHuffAndPuffProfile(), 0.97) if err := ValidateRTP(profile, 0.000000001); err != nil { t.Fatal(err) } } func TestEvaluateSlotHonorsProfileWays(t *testing.T) { profile := SlotProfile{Rows: 3, Reels: 5, Ways: 1, Symbols: []SlotSymbol{{ID: "x", Weight: 1, Payout: map[int]float64{5: 2}}}} grid := [3][5]string{} for row := range grid { for reel := range grid[row] { grid[row][reel] = "x" } } payout, _ := evaluateSlot(grid, 10, profile) if payout != 4860 { t.Fatalf("payout=%v, want 4860 (bet 10 x 2 x 243 ways / 1)", payout) } } func TestEvaluateSlotReportsWinningWays(t *testing.T) { profile := SlotProfile{Rows: 3, Reels: 5, Ways: 243, Symbols: []SlotSymbol{{ID: "x", Weight: 1, Payout: map[int]float64{5: 2}}}} grid := [3][5]string{} for row := range grid { for reel := range grid[row] { grid[row][reel] = "x" } } payout, wins := evaluateSlot(grid, 10, profile) if payout != 20 || len(wins) != 1 || wins[0].Ways != 243 || wins[0].Length != 5 { t.Fatalf("payout=%v wins=%+v", payout, wins) } }