Пример #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)