aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/slots_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/slots_test.go')
-rw-r--r--internal/casino/slots_test.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/casino/slots_test.go b/internal/casino/slots_test.go
new file mode 100644
index 0000000..22e39bf
--- /dev/null
+++ b/internal/casino/slots_test.go
@@ -0,0 +1,44 @@
+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 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)
+ }
+}