Ejemplo n.º 1
0
 def test_convert_999(self):
     try:
         expected = 999
         actual = TextToNumEng.convert('nine hundred ninety nine')
         self.assertEqual(actual, expected)
     except Exception:
         self.assertTrue(False, traceback.format_exc())
Ejemplo n.º 2
0
 def test_string_empty(self):
     try:
         actual = TextToNumEng.convert('')
         self.fail()
         self.assertIsNone(actual)
     except TypeError:
         pass
Ejemplo n.º 3
0
 def test_invalid_scale(self):
     try:
         actual = TextToNumEng.convert('hundred four')
         self.assertIsNone(actual)
     except Exception as e:
         #print type(e), str(e)
         self.assertTrue(isinstance(e, Exception))
Ejemplo n.º 4
0
 def test_number(self):
     expected = 128
     actual = ""
     try:
         actual = TextToNumEng.convert(expected)
         self.assertEqual(expected, actual)
     except TypeError:
         raise
Ejemplo n.º 5
0
 def test_list_string(self):
     words = 'two million fifty thousand one hundred and forty nine'.split()
     expected = 2050149
     actual = TextToNumEng.convert(words)
     self.assertEqual(actual, expected)
Ejemplo n.º 6
0
 def test_hyphen(self):
     expected = 41
     actual = TextToNumEng.convert('forty-one')
     self.assertEqual(actual, expected)
Ejemplo n.º 7
0
 def test_convert_millions_thousands_hundreds_and_tens_ones(self):
     expected = 2050149
     actual = TextToNumEng.convert(
         'two million fifty thousand one hundred and forty nine')
     self.assertEqual(actual, expected)
Ejemplo n.º 8
0
 def test_convert_hundreds_and_tens_ones(self):
     expected = 249
     actual = TextToNumEng.convert('two hundred and forty nine')
     self.assertEqual(actual, expected)
Ejemplo n.º 9
0
 def test_not_number(self):
     try:
         actual = TextToNumEng.convert('hi there')
         self.assertIsNone(actual)
     except Exception as e:
         self.assertTrue(isinstance(e, Exception))
Ejemplo n.º 10
0
 def test_convert_94(self):
     expected = 94
     actual = TextToNumEng.convert('ninety four')
     self.assertEqual(actual, expected)
Ejemplo n.º 11
0
 def test_convert_tens_ones(self):
     expected = 92
     actual = TextToNumEng.convert('ninety two')
     self.assertEqual(actual, expected)
Ejemplo n.º 12
0
 def test_convert_scales(self):
     expected = 500
     actual = TextToNumEng.convert("five hundred")
     self.assertEqual(actual, expected)
Ejemplo n.º 13
0
 def test_convert_tens(self):
     expected = 20
     actual = TextToNumEng.convert('twenty')
     self.assertEqual(actual, expected)
Ejemplo n.º 14
0
 def test_convert_teens(self):
     expected = 19
     actual = TextToNumEng.convert('nineteen')
     self.assertEqual(actual, expected)
Ejemplo n.º 15
0
 def test_convert_ones(self):
     expected = 4
     actual = TextToNumEng.convert('four')
     self.assertEqual(actual, expected)