Files
se-poker/poker_test.go
2025-12-22 16:45:48 +01:00

85 lines
2.1 KiB
Go

package main
import (
"testing"
)
func TestRoyalFlush(t *testing.T) {
hand, _ := NewHand("CT CJ CQ CK CA")
result := hand.Evaluate()
if result.Category != RoyalFlush {
t.Errorf("Expected RoyalFlush, got %s", handNames[result.Category])
}
}
func TestStraightFlush(t *testing.T) {
hand, _ := NewHand("D8 D9 DT DJ DQ")
result := hand.Evaluate()
if result.Category != StraightFlush {
t.Errorf("Expected StraightFlush, got %s", handNames[result.Category])
}
}
func TestFourOfAKind(t *testing.T) {
hand, _ := NewHand("HT SQ ST DT CT")
result := hand.Evaluate()
if result.Category != FourOfAKind {
t.Errorf("Expected FourOfAKind, got %s", handNames[result.Category])
}
}
func TestFullHouse(t *testing.T) {
hand, _ := NewHand("H2 SQ C2 D2 CQ")
result := hand.Evaluate()
if result.Category != FullHouse {
t.Errorf("Expected FullHouse, got %s", handNames[result.Category])
}
}
func TestFlush(t *testing.T) {
hand, _ := NewHand("HK HQ H2 H4 H5")
result := hand.Evaluate()
if result.Category != Flush {
t.Errorf("Expected Flush, got %s", handNames[result.Category])
}
}
func TestStraight(t *testing.T) {
hand, _ := NewHand("H3 S7 H5 D6 H4")
result := hand.Evaluate()
if result.Category != Straight {
t.Errorf("Expected Straight, got %s", handNames[result.Category])
}
}
func TestThreeOfAKind(t *testing.T) {
hand, _ := NewHand("H2 SQ S2 D2 CK")
result := hand.Evaluate()
if result.Category != ThreeOfAKind {
t.Errorf("Expected ThreeOfAKind, got %s", handNames[result.Category])
}
}
func TestTwoPair(t *testing.T) {
hand, _ := NewHand("H5 SQ C5 DT CT")
result := hand.Evaluate()
if result.Category != TwoPair {
t.Errorf("Expected TwoPair, got %s", handNames[result.Category])
}
}
func TestPair(t *testing.T) {
hand, _ := NewHand("H3 S8 H5 D8 CA")
result := hand.Evaluate()
if result.Category != Pair {
t.Errorf("Expected Pair, got %s", handNames[result.Category])
}
}
func TestHighCard(t *testing.T) {
hand, _ := NewHand("H3 S8 H5 DK CA")
result := hand.Evaluate()
if result.Category != HighCard {
t.Errorf("Expected HighCard, got %s", handNames[result.Category])
}
}