2023-07-21 16:54:40 -07:00
|
|
|
# These tests are auto-generated with test data from:
|
|
|
|
|
# https://github.com/exercism/problem-specifications/tree/main/exercises/yacht/canonical-data.json
|
|
|
|
|
# File last updated on 2023-07-19
|
2018-04-11 01:34:00 +08:00
|
|
|
|
2023-07-21 16:54:40 -07:00
|
|
|
import unittest
|
2018-04-11 01:34:00 +08:00
|
|
|
import yacht
|
|
|
|
|
|
2019-10-05 10:26:05 +08:00
|
|
|
|
2018-06-13 09:12:09 -04:00
|
|
|
class YachtTest(unittest.TestCase):
|
2018-04-11 01:34:00 +08:00
|
|
|
def test_yacht(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([5, 5, 5, 5, 5], yacht.YACHT), 50)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_not_yacht(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([1, 3, 3, 2, 5], yacht.YACHT), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_ones(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([1, 1, 1, 3, 5], yacht.ONES), 3)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_ones_out_of_order(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([3, 1, 1, 5, 1], yacht.ONES), 3)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_no_ones(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([4, 3, 6, 5, 5], yacht.ONES), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_twos(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([2, 3, 4, 5, 6], yacht.TWOS), 2)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_fours(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([1, 4, 1, 4, 1], yacht.FOURS), 8)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_yacht_counted_as_threes(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([3, 3, 3, 3, 3], yacht.THREES), 15)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
2019-06-20 15:22:06 +02:00
|
|
|
def test_yacht_of_3s_counted_as_fives(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([3, 3, 3, 3, 3], yacht.FIVES), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
2022-05-05 20:08:32 -07:00
|
|
|
def test_fives(self):
|
|
|
|
|
self.assertEqual(yacht.score([1, 5, 3, 5, 3], yacht.FIVES), 10)
|
|
|
|
|
|
2018-04-11 01:34:00 +08:00
|
|
|
def test_sixes(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([2, 3, 4, 5, 6], yacht.SIXES), 6)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_full_house_two_small_three_big(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([2, 2, 4, 4, 4], yacht.FULL_HOUSE), 16)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_full_house_three_small_two_big(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([5, 3, 3, 5, 3], yacht.FULL_HOUSE), 19)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_two_pair_is_not_a_full_house(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([2, 2, 4, 4, 5], yacht.FULL_HOUSE), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
2018-05-03 02:45:25 +08:00
|
|
|
def test_four_of_a_kind_is_not_a_full_house(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([1, 4, 4, 4, 4], yacht.FULL_HOUSE), 0)
|
2018-05-03 02:45:25 +08:00
|
|
|
|
2018-04-11 01:34:00 +08:00
|
|
|
def test_yacht_is_not_a_full_house(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([2, 2, 2, 2, 2], yacht.FULL_HOUSE), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_four_of_a_kind(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([6, 6, 4, 6, 6], yacht.FOUR_OF_A_KIND), 24)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_yacht_can_be_scored_as_four_of_a_kind(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([3, 3, 3, 3, 3], yacht.FOUR_OF_A_KIND), 12)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_full_house_is_not_four_of_a_kind(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([3, 3, 3, 5, 5], yacht.FOUR_OF_A_KIND), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_little_straight(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([3, 5, 4, 1, 2], yacht.LITTLE_STRAIGHT), 30)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_little_straight_as_big_straight(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([1, 2, 3, 4, 5], yacht.BIG_STRAIGHT), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_four_in_order_but_not_a_little_straight(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([1, 1, 2, 3, 4], yacht.LITTLE_STRAIGHT), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_no_pairs_but_not_a_little_straight(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([1, 2, 3, 4, 6], yacht.LITTLE_STRAIGHT), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
2019-06-20 15:22:06 +02:00
|
|
|
def test_minimum_is_1_maximum_is_5_but_not_a_little_straight(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([1, 1, 3, 4, 5], yacht.LITTLE_STRAIGHT), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_big_straight(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([4, 6, 2, 5, 3], yacht.BIG_STRAIGHT), 30)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_big_straight_as_little_straight(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([6, 5, 4, 3, 2], yacht.LITTLE_STRAIGHT), 0)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
2019-06-20 15:22:06 +02:00
|
|
|
def test_no_pairs_but_not_a_big_straight(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([6, 5, 4, 3, 1], yacht.BIG_STRAIGHT), 0)
|
2019-06-20 15:22:06 +02:00
|
|
|
|
2018-04-11 01:34:00 +08:00
|
|
|
def test_choice(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([3, 3, 5, 6, 6], yacht.CHOICE), 23)
|
2018-04-11 01:34:00 +08:00
|
|
|
|
|
|
|
|
def test_yacht_as_choice(self):
|
2019-10-05 10:26:05 +08:00
|
|
|
self.assertEqual(yacht.score([2, 2, 2, 2, 2], yacht.CHOICE), 10)
|