示例#1
0
 def test_addDigitCorrectlyGoesFrom0To3To30To309(self):
     num = Number()
     num.add_digit(3)
     self.assertEqual(num.value, 3)
     num.add_digit(0)
     self.assertEqual(num.value, 30)
     num.add_digit(9)
     self.assertEqual(num.value, 309)
示例#2
0
 def test_addDigitCorrectlyGoesFrom0To4(self):
     num = Number()
     num.add_digit(4)
     self.assertEqual(num.value, 4)
示例#3
0
 def test_NumberStartsAtZero(self):
     num = Number()
     self.assertEqual(num.value, 0)
示例#4
0
 def test_removeDigitGoesFrom309To30To3To0(self):
     num = Number()
     num.add_digit(3)
     self.assertEqual(num.value, 3)
     num.add_digit(0)
     self.assertEqual(num.value, 30)
     num.add_digit(9)
     self.assertEqual(num.value, 309)
     num.remove_digit()
     self.assertEqual(num.value, 30)
     num.remove_digit()
     self.assertEqual(num.value, 3)
     num.remove_digit()
     self.assertEqual(num.value, 0)
示例#5
0
 def test_addDigitThrowsExceptionWhenGivenToSmallAnInteger(self):
     num = Number()
     with self.assertRaises(DigitOutOfRangeException):
         num.add_digit(-1)
示例#6
0
 def test_addDigitDoesNotChangeWhenGiven0AsTheFirstDigit(self):
     num = Number()
     num.add_digit(0)
     self.assertEqual(num.value, 0)
示例#7
0
 def test_addDigitCorrectlyGoesFrom0To3To36(self):
     num = Number()
     num.add_digit(3)
     num.add_digit(6)
     self.assertEqual(num.value, 36)