diff --git a/tests/test_base.py b/tests/test_base.py index efa1bc81..7d0cbd7d 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -62,3 +62,56 @@ def test_is_title(self): self.base.title("one"), "one" ) + + def test_set_high_numwords_not_implemented(self): + with self.assertRaises(NotImplementedError): + self.base.set_high_numwords() + +class SplitNumTest(TestCase): + def setUp(self): + self.base = Num2Word_Base() + + def test_splitnum_zero(self): + value = 0 + expected = [] + result = self.base.splitnum(value) + self.assertEqual(result, expected) + + def test_splitnum_single_digit(self): + value = 5 + expected = [('five', 5)] + result = self.base.splitnum(value) + self.assertEqual(result, expected) + + def test_splitnum_multiple_digits(self): + value = 1234 + expected = [('one thousand', 1000), + ('two hundred', 100), + ('thirty', 10), + ('four', 1)] + result = self.base.splitnum(value) + self.assertEqual(result, expected) + + def test_splitnum_decimal(self): + value = Decimal('1234.56') + expected = [('one thousand', 1000), + ('two hundred', 100), + ('thirty', 10), ('four', 1), + ('point', 0), ('five', Decimal('0.5')), + ('six', Decimal('0.06'))] + result = self.base.splitnum(value) + self.assertEqual(result, expected) + + def test_splitnum_large_value(self): + value = 9876543210 + expected = [('nine billion', 1000000000), + ('eight hundred', 100000000), + ('seventy', 10000000), + ('six million', 1000000), + ('five hundred', 100000), + ('forty', 10000), + ('three thousand', 1000), + ('two hundred', 100), + ('ten', 10)] + result = self.base.splitnum(value) + self.assertEqual(result, expected)