Skip to content

Commit

Permalink
Add test to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlon Rodriguez Garcia committed Nov 19, 2024
1 parent 8c712e9 commit f426817
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit f426817

Please sign in to comment.