示例#1
0
 def test_twopair(self):
     d = self.d
     hand = Hand.get_twopair([d.hk, d.ck, d.dq, d.sq, d.hj])
     assert(hand is not None and hand.category == Hand.TWOPAIR)
     hand = Hand.get_twopair([d.ht, d.cq, d.dq, d.dj, d.dt])
     assert(hand is not None and hand.category == Hand.TWOPAIR)
     hand = Hand.get_twopair([d.st, d.sq, d.ct, d.cj, d.ck])
     assert(hand is None)
示例#2
0
 def test_twopair_compare(self):
     d = self.d
     # d2 cj ck d8 s4 - c2 c8 - sj s8 - h8 s2
     twopair1 = Hand.get_twopair([d.c2, d.c8, d.d2, d.ck, d.d8])
     twopair2 = Hand.get_twopair([d.sj, d.s8, d.cj, d.ck, d.d8])
     twopair3 = Hand.get_twopair([d.h8, d.s2, d.d2, d.ck, d.d8])
     assert(twopair1 is not None)
     assert(twopair1 < twopair2 and twopair2 > twopair1)
     assert(twopair2 > twopair3 and twopair3 < twopair2)
     assert(twopair1 == twopair3 and twopair3 == twopair1)
示例#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)