-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_string_helpers.py
19 lines (16 loc) · 953 Bytes
/
test_string_helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from unittest import TestCase
from icloudpd.string_helpers import truncate_middle
class TruncateMiddleTestCase(TestCase):
def test_truncate_middle(self) -> None:
assert truncate_middle("test_filename.jpg", 50) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 17) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 16) == "test_f...me.jpg"
assert truncate_middle("test_filename.jpg", 10) == "tes...jpg"
assert truncate_middle("test_filename.jpg", 5) == "t...g"
assert truncate_middle("test_filename.jpg", 4) == "...g"
assert truncate_middle("test_filename.jpg", 3) == "..."
assert truncate_middle("test_filename.jpg", 2) == ".."
assert truncate_middle("test_filename.jpg", 1) == "."
assert truncate_middle("test_filename.jpg", 0) == ""
with self.assertRaises(ValueError):
truncate_middle("test_filename.jpg", -1)