summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index c2fb9c2c..9dd54ee2 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -317,6 +317,13 @@ def test_truncate_line_wide_text():
truncated = cu.truncate_line(line, max_width)
assert truncated == '苹苹o\N{HORIZONTAL ELLIPSIS}'
+def test_truncate_line_split_wide_text():
+ """Test when truncation results in a string which is shorter than max_width"""
+ line = '1苹2苹'
+ max_width = 3
+ truncated = cu.truncate_line(line, max_width)
+ assert truncated == '1\N{HORIZONTAL ELLIPSIS}'
+
def test_truncate_line_tabs():
line = 'has\ttab'
max_width = 9
@@ -379,6 +386,14 @@ def test_align_text_wider_than_width_truncate():
aligned = cu.align_text(text, cu.TextAlignment.LEFT, fill_char=fill_char, width=width, truncate=True)
assert aligned == 'long te\N{HORIZONTAL ELLIPSIS}'
+def test_align_text_wider_than_width_truncate_add_fill():
+ """Test when truncation results in a string which is shorter than width and align_text adds filler"""
+ text = '1苹2苹'
+ fill_char = '-'
+ width = 3
+ aligned = cu.align_text(text, cu.TextAlignment.LEFT, fill_char=fill_char, width=width, truncate=True)
+ assert aligned == '1\N{HORIZONTAL ELLIPSIS}-'
+
def test_align_text_has_unprintable():
text = 'foo\x02'
fill_char = '-'