task1
This commit is contained in:
12
run_tests.py
12
run_tests.py
@@ -19,7 +19,7 @@ def test_basic_card_functionality():
|
||||
assert str(card) == "As", f"Expected 'As', got '{str(card)}'"
|
||||
|
||||
# Test card parsing
|
||||
parsed_card = Card.from_string("Kh")
|
||||
parsed_card = Card.createCard("Kh")
|
||||
assert parsed_card.rank == Rank.KING
|
||||
assert parsed_card.suit == Suit.HEARTS
|
||||
|
||||
@@ -35,7 +35,7 @@ def test_hand_parsing():
|
||||
"""Test hand parsing from string"""
|
||||
print("Testing hand parsing...")
|
||||
|
||||
cards = Card.parse_cards("AsKs AhAdAc6s7s")
|
||||
cards = Card.parseCards("AsKs AhAdAc6s7s")
|
||||
assert len(cards) == 7, f"Expected 7 cards, got {len(cards)}"
|
||||
assert str(cards[0]) == "As"
|
||||
assert str(cards[6]) == "7s"
|
||||
@@ -61,7 +61,7 @@ def test_hand_evaluation_examples():
|
||||
]
|
||||
|
||||
for cards_str, expected_str, expected_type in test_cases:
|
||||
ranking = HandEvaluator.evaluate_from_input(cards_str)
|
||||
ranking = HandEvaluator.evaluateFromInput(cards_str)
|
||||
actual_str = str(ranking)
|
||||
|
||||
assert ranking.hand_type == expected_type, f"Wrong hand type for {cards_str}: expected {expected_type}, got {ranking.hand_type}"
|
||||
@@ -75,7 +75,7 @@ def test_wheel_straight():
|
||||
print("Testing wheel straight...")
|
||||
|
||||
cards_str = "As2h3d4c5h7s8s"
|
||||
ranking = HandEvaluator.evaluate_from_input(cards_str)
|
||||
ranking = HandEvaluator.evaluateFromInput(cards_str)
|
||||
|
||||
assert ranking.hand_type == HandType.STRAIGHT
|
||||
assert ranking.key_ranks[0] == Rank.FIVE, "In wheel straight, 5 should be the high card"
|
||||
@@ -90,14 +90,14 @@ def test_error_handling():
|
||||
|
||||
# Test invalid card string
|
||||
try:
|
||||
Card.from_string("Xx")
|
||||
Card.createCard("Xx")
|
||||
assert False, "Should have raised ValueError for invalid card"
|
||||
except ValueError:
|
||||
pass # Expected
|
||||
|
||||
# Test wrong number of cards
|
||||
try:
|
||||
HandEvaluator.evaluate_from_input("AsKh")
|
||||
HandEvaluator.evaluateFromInput("AsKh")
|
||||
assert False, "Should have raised ValueError for wrong number of cards"
|
||||
except ValueError:
|
||||
pass # Expected
|
||||
|
||||
Reference in New Issue
Block a user