Exemplo n.º 1
0
    def test_pretty_one_line(self):
        constraints = HandConstraints()
        self.assertEqual(constraints.pretty_one_line(), "?")
        constraints.set_min_hcp(3)
        constraints.set_min_length(CLUBS, 3)
        self.assertEqual(constraints.pretty_one_line(), "3+ hcp, 3+C")

        constraints = HandConstraints()
        constraints.set_min_hcp(3)
        constraints.set_min_length(CLUBS, 3)
        constraints.set_min_length(DIAMONDS, 3)
        self.assertEqual(constraints.pretty_one_line(), "3+ hcp, 3+C 3+D")
Exemplo n.º 2
0
    def test_compute_implied_suit_length_ranges(self):
        constraints = HandConstraints()
        constraints.set_min_length(CLUBS, 3)
        constraints.set_min_length(DIAMONDS, 3)
        constraints.set_min_length(HEARTS, 3)
        self.assertEqual(constraints.max_length(SPADES), 4)

        constraints = HandConstraints()
        constraints.set_max_length(CLUBS, 5)
        constraints.set_longest_suit(CLUBS)
        self.assertEqual(constraints.pretty_one_line(), "? hcp, 4-5C 0-5D 0-5H 0-5S")

        constraints = HandConstraints()
        constraints.set_max_length(CLUBS, 5)
        constraints.set_longest_suit(CLUBS, except_suits=[HEARTS])
        self.assertEqual(constraints.pretty_one_line(), "? hcp, 4-5C 0-5D 0-5S")

        constraints = HandConstraints()
        constraints.set_min_length(DIAMONDS, 3)
        constraints.set_longer_minor(DIAMONDS)
        self.assertEqual(constraints.min_length(DIAMONDS), 3)
        constraints.set_min_length(CLUBS, 4)
        self.assertEqual(constraints.min_length(DIAMONDS), 4)

        constraints = HandConstraints()
        constraints.set_min_length(HEARTS, 3)
        constraints.set_longer_major(HEARTS)
        self.assertEqual(constraints.min_length(HEARTS), 3)
        constraints.set_min_length(SPADES, 4)
        self.assertEqual(constraints.min_length(HEARTS), 4)