def test_can_double_down(self): data = (([Card(101), Card(201)], True), ([Card(112), Card(413)], True), ([Card(109), Card(209), Card(309)], False)) for handlist, actual in data: with self.subTest(handlist=handlist, actual=actual): self.player.hand.hand = handlist self.assertEqual(self.player.can_double_down(), actual)
def test_num_suit(self): data = [(101, 1), (201, 2), (301, 3), (401, 4)] for number, actual in data: self.assertEqual(Card(number).num_suit, actual)
def test_display_rank(self): data = [(101, "A"), (105, "5"), (110, "10"), (111, "J"), (112, "Q"), (113, "K")] for number, actual in data: self.assertEqual(Card(number).display_rank, actual)
def test_display_suit(self): data = [(101, "ハート"), (201, "スペード"), (301, "ダイヤ"), (401, "クラブ")] for number, actual in data: self.assertEqual(Card(number).display_suit, actual)
def test_num_rank(self): data = [(101, (1, 11)), (105, 5), (110, 10), (211, 10), (312, 10), (313, 10)] for number, actual in data: self.assertEqual(Card(number).num_rank, actual)
def test_calculate_total_score(self): data = (([Card(101), Card(112)], 21), ([Card(113), Card(212), Card(402)], 22), ([Card(101), Card(201), Card(301), Card(401)], 14), ([Card(101), Card(301), Card(103)], 15), ([Card(101), Card(301), Card(210)], 12), ([Card(101), Card(301), Card(304), Card(313), Card(408)], 24)) for handlist, actual in data: with self.subTest(handlist=handlist, actual=actual): self.testHand.hand = handlist self.assertEqual(self.testHand.calculate_total_score(), actual)
def test_is_natural_blackjack(self): data = [([Card(301), Card(112)], True), ([Card(313), Card(301)], True), ([Card(301), Card(213), Card(102)], False), ([Card(301), Card(303), Card(207)], False), ([Card(408), Card(203), Card(102), Card(406), Card(302)], False)] for handlist, actual in data: with self.subTest(hanlist=handlist, actual=actual): self.testHand.hand = handlist self.assertIs(self.testHand.is_natural_blackjack(), actual)
def test_is_busted(self): data = (([Card(301), Card(110)], False), ([Card(213), Card(401), Card(202)], False), ([Card(101), Card(201), Card(301), Card(401)], False), ([Card(201), Card(101), Card(103)], False), ([Card(401), Card(201), Card(113)], False), ([Card(101), Card(401), Card(204), Card(310), Card(308)], True), ([Card(205), Card(105), Card(102), Card(405), Card(206)], True)) for handlist, actual in data: with self.subTest(handlist=handlist, actual=actual): self.testHand.hand = handlist self.assertIs(self.testHand.is_busted(), actual)
def __init__(self): self.__deck = [] for suit in range(1, 5): for rank in range(1, 14): self.__deck.append(Card(suit * 100 + rank)) shuffle(self.__deck)
def test_is_continue(self): data = [([Card(103), Card(204), Card(205)], True), ([Card(101), Card(403), Card(405), Card(206)], True), ([Card(101), Card(202), Card(404)], False), ([Card(101), Card(408), Card(105), Card(303)], False), ([Card(101), Card(112)], False), ([Card(101), Card(108), Card(202)], False)] for handlist, actual in data: with self.subTest(handlist=handlist, actual=actual): self.dealer.hand.hand = handlist self.assertIs(self.dealer.is_continue(), actual)