mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
25 lines
996 B
Python
25 lines
996 B
Python
|
|
from unittest import TestCase
|
||
|
|
|
||
|
|
from num2words.utils import splitbyx
|
||
|
|
|
||
|
|
|
||
|
|
class TestUtils(TestCase):
|
||
|
|
def test_splitbyx(self):
|
||
|
|
self.assertEqual(list(splitbyx(str(12), 3)), [12])
|
||
|
|
self.assertEqual(list(splitbyx(str(1234), 3)), [1, 234])
|
||
|
|
self.assertEqual(list(splitbyx(str(12345678900), 3)),
|
||
|
|
[12, 345, 678, 900]
|
||
|
|
)
|
||
|
|
self.assertEqual(list(splitbyx(str(1000000), 6)), [1, 0])
|
||
|
|
|
||
|
|
self.assertEqual(list(splitbyx(str(12), 3, format_int=False)), ['12'])
|
||
|
|
self.assertEqual(list(splitbyx(str(1234), 3, format_int=False)),
|
||
|
|
['1', '234']
|
||
|
|
)
|
||
|
|
self.assertEqual(list(splitbyx(str(12345678900), 3, format_int=False)),
|
||
|
|
['12', '345', '678', '900']
|
||
|
|
)
|
||
|
|
self.assertEqual(list(splitbyx(str(1000000), 6, format_int=False)),
|
||
|
|
['1', '000000']
|
||
|
|
)
|