fix edge cases, add tests

This commit is contained in:
InspectorCaracal 2022-10-14 11:59:42 -06:00
parent 0f70f51724
commit b06e8cefde
2 changed files with 19 additions and 7 deletions

View file

@ -66,8 +66,12 @@ class TestListToString(TestCase):
[1,2,3] -> '1, 2, 3'
with sep==';' and endsep==';':
[1,2,3] -> '1; 2; 3'
with sep=='or':
[1,2,3] -> '1 or 2, and 3'
with endsep=='and':
[1,2,3] -> '1, 2 and 3'
with endsep=='; and':
[1,2,3] -> '1, 2; and 3'
with endsep=='':
[1,2,3] -> '1, 2 3'
with addquote and endsep="and"
@ -80,6 +84,8 @@ class TestListToString(TestCase):
self.assertEqual("1, 2 and 3", utils.list_to_string([1, 2, 3], endsep="and"))
self.assertEqual("1, 2 3", utils.list_to_string([1, 2, 3], endsep=""))
self.assertEqual("1; 2; 3", utils.list_to_string([1, 2, 3], sep=";", endsep=";"))
self.assertEqual("1 or 2, and 3", utils.list_to_string([1, 2, 3], sep="or"))
self.assertEqual("1, 2; and 3", utils.list_to_string([1, 2, 3], endsep="; and"))
self.assertEqual(
'"1", "2", "3"', utils.list_to_string([1, 2, 3], endsep=",", addquote=True)
)