Example #1
0
 def test_threeofakind_compare(self):
     d = self.d
     # c5 d5 dj ca s3 - s5 s7 - sj cj - h5 ck
     trip1 = Hand.get_threeofakind([d.s5, d.c5, d.d5, d.dj, d.ca])
     trip2 = Hand.get_threeofakind([d.sj, d.cj, d.c5, d.dj, d.ca])
     trip3 = Hand.get_threeofakind([d.h5, d.ck, d.c5, d.d5, d.ca])
     assert(trip1 is not None)
     assert(trip1 < trip2 and trip2 > trip1)
     assert(trip2 > trip3 and trip3 < trip2)
     assert(trip1 < trip3 and trip3 > trip1)
Example #2
0
 def test_threeofakind(self):
     d = self.d
     hand = Hand.get_threeofakind([d.ck, d.sk, d.dk, d.d2, d.c3])
     assert(hand is not None and hand.category == Hand.THREEOFAKIND)
     hand = Hand.get_threeofakind([d.ck, d.sk, d.d2, d.s2, d.d3])
     assert(hand is None)
     hand = Hand.get_threeofakind([d.ck, d.sk, d.dk, d.hk, d.h3])
     assert(hand is not None and hand.category == Hand.THREEOFAKIND)
     hand = Hand.get_threeofakind([d.hk, d.sk, d.dk, d.d2, d.s2])
     assert(hand is not None and hand.category == Hand.THREEOFAKIND)
Example #3
0
 def test_different_categories_compare(self):
     d = self.d
     hands = [Hand.get_highcard([d.h6, d.c9, d.d2, d.ck, d.cj]),
              Hand.get_pair([d.cj, d.sq, d.d2, d.c2, d.s4]),
              Hand.get_twopair([d.sj, d.cq, d.da, d.dq, d.hj]),
              Hand.get_threeofakind([d.d3, d.h8, d.c4, d.d8, d.s8]),
              Hand.get_straight([d.d7, d.h4, d.c5, d.c3, d.d6]),
              Hand.get_flush([d.h4, d.h8, d.h5, d.hq, d.h2]),
              Hand.get_fullhouse([d.d8, d.c8, d.s6, d.s8, d.c6]),
              Hand.get_fourofakind([d.h9, d.c7, d.d9, d.c9, d.s9]),
              Hand.get_straightflush([d.c3, d.c5, d.c4, d.c2, d.c6])]
     for hand in hands:
         assert(hand is not None)
     for hand1, hand2 in combinations(hands, 2):
         assert(hand1 < hand2)
     hands.reverse()
     for hand1, hand2 in combinations(hands, 2):
         assert(hand1 > hand2)