diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-12-09 17:35:44 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-12-09 17:35:44 -0500 |
commit | 4c3cd737d780819f02664f4d49edbebab08ee8a8 (patch) | |
tree | 1fd157109d075672eb3409d3852ca7c1e6cf93a1 /tests | |
parent | 6c522569ae9404528e9a3dfe9a1d4e769043e5e7 (diff) | |
download | cmd2-git-4c3cd737d780819f02664f4d49edbebab08ee8a8.tar.gz |
Added more unit tests for text alignment
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_utils.py | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index 745e5ff4..233b3b70 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -369,15 +369,21 @@ def test_left_text_multiline(): assert aligned == ('foo----\n' 'shoes--') -def test_left_text_asian_fill(): - """Test fill_char with display width greater than 1""" +def test_left_wide_display_text(): + text = '苹' + fill_char = '-' + width = 4 + aligned = cu.ljustify_text(text, fill_char=fill_char, width=width) + assert aligned == text + fill_char + fill_char + +def test_left_text_wide_display_fill(): text = 'foo' fill_char = '苹' width = 5 aligned = cu.ljustify_text(text, fill_char=fill_char, width=width) assert aligned == text + fill_char -def test_left_text_asian_fill_needs_padding(): +def test_left_text_wide_display_fill_needs_padding(): """Test when fill_char's display width does not divide evenly into gap""" text = 'foo' fill_char = '苹' @@ -400,15 +406,21 @@ def test_center_text_multiline(): assert aligned == ('--foo--\n' '-shoes-') -def test_center_text_asian_fill(): - """Test fill_char with display width greater than 1""" +def test_center_wide_display_text(): + text = '苹' + fill_char = '-' + width = 4 + aligned = cu.center_text(text, fill_char=fill_char, width=width) + assert aligned == fill_char + text + fill_char + +def test_center_text_wide_display_fill(): text = 'foo' fill_char = '苹' width = 7 aligned = cu.center_text(text, fill_char=fill_char, width=width) assert aligned == fill_char + text + fill_char -def test_center_text_asian_fill_needs_right_padding(): +def test_center_text_wide_display_fill_needs_right_padding(): """Test when fill_char's display width does not divide evenly into right gap""" text = 'foo' fill_char = '苹' @@ -416,7 +428,7 @@ def test_center_text_asian_fill_needs_right_padding(): aligned = cu.center_text(text, fill_char=fill_char, width=width) assert aligned == fill_char + text + fill_char + ' ' -def test_center_text_asian_fill_needs_left_and_right_padding(): +def test_center_text_wide_display_fill_needs_left_and_right_padding(): """Test when fill_char's display width does not divide evenly into either gap""" text = 'foo' fill_char = '苹' @@ -439,15 +451,21 @@ def test_right_text_multiline(): assert aligned == ('----foo\n' '--shoes') -def test_right_text_asian_fill(): - """Test fill_char with display width greater than 1""" +def test_right_wide_display_text(): + text = '苹' + fill_char = '-' + width = 4 + aligned = cu.rjustify_text(text, fill_char=fill_char, width=width) + assert aligned == fill_char + fill_char + text + +def test_right_text_wide_display_fill(): text = 'foo' fill_char = '苹' width = 5 aligned = cu.rjustify_text(text, fill_char=fill_char, width=width) assert aligned == fill_char + text -def test_right_text_asian_fill_needs_padding(): +def test_right_text_wide_display_fill_needs_padding(): """Test when fill_char's display width does not divide evenly into gap""" text = 'foo' fill_char = '苹' |