def testAdd(self): """Test Poker Chips : Addition""" values = [5, 10, 20] pokerchip1 = pokerchips.PokerChips(values, 155) pokerchip2 = pokerchips.PokerChips(values, 223) pokerchip1.add(pokerchip2) self.failUnlessEqual(pokerchip1.toint(), 155 + 223)
def testlimitChips(self): """Test Poker Chips : Limit chips""" values = [5, 10, 20] chips = pokerchips.PokerChips(values, [pokerchips.MAX_CHIPS_PER_STACK + 2, 0, 0]) self.failUnlessEqual(chips.tolist(), [5, pokerchips.MAX_CHIPS_PER_STACK, 10, 1]) chips = pokerchips.PokerChips(values, [pokerchips.MAX_CHIPS_PER_STACK + 3, 0, 0]) self.failUnlessEqual(chips.tolist(), [5, pokerchips.MAX_CHIPS_PER_STACK + 1, 10, 1]) chips = pokerchips.PokerChips(values, [pokerchips.MAX_CHIPS_PER_STACK + 4, pokerchips.MAX_CHIPS_PER_STACK, pokerchips.MAX_CHIPS_PER_STACK]) self.failUnlessEqual(chips.tolist(), [5, pokerchips.MAX_CHIPS_PER_STACK, 10, pokerchips.MAX_CHIPS_PER_STACK, 20, pokerchips.MAX_CHIPS_PER_STACK +1])
def testToInt(self): """Test Poker Chips : To integer""" values = [5, 10, 20] pokerchip = pokerchips.PokerChips(values) self.failUnlessEqual(pokerchip.toint(), 0) pokerchip = pokerchips.PokerChips(values, 153) self.failUnlessEqual(pokerchip.toint(), 153) pokerchip = pokerchips.PokerChips(values, [1, 1, 1]) self.failUnlessEqual(pokerchip.toint(), 35)
def testOperatorEqu(self): """Test Poker Chips : Equality""" values = [5, 10, 20] pokerchip1 = pokerchips.PokerChips(values, 153) pokerchip2 = pokerchips.PokerChips(values, 153) pokerchip3 = pokerchips.PokerChips(values, 154) self.failUnlessEqual(pokerchip1, pokerchip2) self.failIfEqual(pokerchip1, pokerchip3) self.failUnlessEqual(pokerchip1 != pokerchip2, False) self.failUnlessEqual(pokerchip1 != pokerchip3, True) self.failUnlessEqual(pokerchip1 != 153, True)
def testReprOperator(self): """Test Poker Chips : Representation""" values = [5, 10, 20] pokerchip = pokerchips.PokerChips(values, 93) self.failUnlessEqual(repr(pokerchip), '%s(%s)' % ('PokerChips', [6, 4, 1]))
def testStrOperator(self): """Test Poker Chips : String representation""" values = [5, 10, 20] pokerchip = pokerchips.PokerChips(values, 93) self.failUnlessEqual(str(pokerchip), 'PokerChips(%s) = %d (-%d)' % ([6, 4, 1], 93, 3))
def testInit(self): """Test Poker Chips : Initialisation""" values = [5, 10, 20] pokerchip = pokerchips.PokerChips(values) self.failUnlessEqual(pokerchip, pokerchips.PokerChips(values, 0)) self.failUnlessEqual(pokerchip.toint(), 0) pokerchip1 = pokerchips.PokerChips(values, 153) pokerchip2 = pokerchips.PokerChips(values, pokerchip1) self.failUnlessEqual(pokerchip1, pokerchip2) self.failUnlessEqual(pokerchip2.toint(), 153) pokerchip1 = pokerchips.PokerChips(values, [10, 5, 1]) self.failUnlessEqual(pokerchip1.toint(), 120)
def testSub(self): """Test Poker Chips : Substraction""" values = [5, 10, 20] pokerchip1 = pokerchips.PokerChips(values, [3, 2, 1]) pokerchip2 = pokerchips.PokerChips(values, [1, 1, 1]) pokerchip1.subtract(pokerchip2) self.failUnlessEqual(pokerchip1, pokerchips.PokerChips(values, [2, 1, 0])) pokerchip1 = pokerchips.PokerChips(values, 155) pokerchip1.subtract(130) self.failUnlessEqual(pokerchip1.toint(), 25) pokerchip1 = pokerchips.PokerChips(values, 155) pokerchip1.subtract(160) self.failUnlessEqual(pokerchip1.toint(), 0)
def testToList(self): """Test Poker Chips : To list""" values = [5, 10, 20] self.failUnlessEqual(pokerchips.PokerChips(values, 0).tolist(), []) self.failUnlessEqual(pokerchips.PokerChips(values, 3).tolist(), [1,3]) self.failUnlessEqual(pokerchips.PokerChips(values, 5).tolist(), [5, 1]) self.failUnlessEqual(pokerchips.PokerChips(values, 7).tolist(), [1, 2 ,5, 1]) self.failUnlessEqual(pokerchips.PokerChips(values, 15).tolist(), [5, 3]) self.failUnlessEqual(pokerchips.PokerChips(values, 50).tolist(), [5, 8, 10, 1]) self.failUnlessEqual(pokerchips.PokerChips(values, 90).tolist(), [5, 8, 10, 3, 20, 1]) self.failUnlessEqual(pokerchips.PokerChips(values, 93).tolist(), [1, 3, 5, 6, 10, 4, 20, 1]) values = [1, 2, 4] self.failUnlessEqual(pokerchips.PokerChips(values, 7).tolist(), [1, 7])
def testCopy(self): """Test Poker Chips : Copy""" values = [5, 10, 20] pokerchip1 = pokerchips.PokerChips(values, 93) pokerchip2 = pokerchip1.copy() self.failUnlessEqual(pokerchip1, pokerchip2) self.failUnlessEqual(pokerchip2.toint(), 93) pokerchip1.add(7) self.failIfEqual(pokerchip1, pokerchip2) self.failUnlessEqual(pokerchip1.toint(), 100) self.failUnlessEqual(pokerchip2.toint(), 93)