summaryrefslogtreecommitdiff
path: root/tests/test_utils.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-01-20 15:03:36 -0500
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-01-20 15:03:36 -0500
commite23f9f63fee19bd43bf3fde36eb59392451ccad8 (patch)
treedd1c8ba87c002954d91a1fa8510ac10f5f6e0403 /tests/test_utils.py
parent2c7e9246e2748e9711e4b0e56c022b141f156c82 (diff)
downloadcmd2-git-e23f9f63fee19bd43bf3fde36eb59392451ccad8.tar.gz
Updating unit tests and docs
Diffstat (limited to 'tests/test_utils.py')
-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 = '-'