def test_end_of_time(self): # What happens when we run out of years? last = Turn(WIN, protocol.max_pos_int - 1, seasons=(SPR, SUM, FAL, AUT, WIN)) next = last.next() msg = Message(next) self.assertEqual(msg.fold(), [SPR, protocol.max_pos_int])
def test_max_neg_int(self): # What if we let it overflow the full 14 bits? last = Turn(WIN, protocol.max_neg_int - 1, seasons=(SPR, SUM, FAL, AUT, WIN)) next = last.next() msg = Message(next) self.assertEqual(msg.fold(), [SPR, protocol.max_neg_int])
def test_turn_phase_hex(self): t = Turn(SUM, 1901) self.failUnlessEqual(t.phase(), 0x40)
def test_turn_phase_name(self): t = Turn(SUM, 1901) self.failUnlessEqual(t.phase(), Turn.retreat_phase)
def test_turn_compare_eq(self): fall = Turn(FAL, 1901) self.failUnlessEqual(cmp(fall, fall.key), 0)
def test_turn_compare_gt(self): spring = Turn(SPR, 1901) fall = Turn(FAL, 1901) self.failUnlessEqual(cmp(fall, spring.key), 1)
def test_turn_compare_lt(self): spring = Turn(SPR, 1901) fall = Turn(FAL, 1901) self.failUnlessEqual(cmp(spring, fall), -1)