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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
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)
}
}
|