summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Matusiak <numerodix@gmail.com>2021-05-05 13:19:17 +1000
committerMartin Matusiak <numerodix@gmail.com>2021-05-05 13:19:17 +1000
commit5cf6e1aa867f7f7f396bae45e13380d978017b5f (patch)
tree30d576ec780ae9210ae9b75894cfc5a06b42aa10 /tests
parent5a27bea4e4e9db63d3b769bf9164e081a1302628 (diff)
downloadansicolor-5cf6e1aa867f7f7f396bae45e13380d978017b5f.tar.gz
add test for highlight_string
Diffstat (limited to 'tests')
-rw-r--r--tests/test_colors.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/test_colors.py b/tests/test_colors.py
index d502057..d52e818 100644
--- a/tests/test_colors.py
+++ b/tests/test_colors.py
@@ -149,7 +149,7 @@ def test_highlight_string_nocolor():
+ 'aaa'
) == highlight_string(text, *spanlists, nocolor=True)
-def test_highlight_string_four_layers():
+def test_highlight_string_four_layers_inside_out():
text = "aaabbbcccdddeeefffeeedddcccbbbaaa"
spanlists = [
[(3, 30)],
@@ -184,6 +184,41 @@ def test_highlight_string_four_layers():
+ 'aaa'
) == highlight_string(text, *spanlists, colors=colors)
+def test_highlight_string_four_layers_outside_in():
+ text = 'fffeeedddcccbbbaaabbbcccdddeeefff'
+ spanlists = [
+ [(12, 21)],
+ [(9, 24)],
+ [(6, 27)],
+ [(3, 30)]
+ ]
+ colors = [
+ Colors.Green,
+ Colors.Yellow,
+ Colors.Cyan,
+ Colors.Blue,
+ ]
+
+ assert (
+ 'fff'
+ + get_code(Colors.Blue)
+ + 'eee'
+ + get_code(Colors.Blue, bold=True)
+ + 'ddd'
+ + get_code(Colors.Blue, reverse=True)
+ + 'ccc'
+ + get_code(Colors.Blue, bold=True, reverse=True)
+ + 'bbbaaabbb'
+ + get_code(Colors.Blue, reverse=True)
+ + 'ccc'
+ + get_code(Colors.Blue, bold=True)
+ + 'ddd'
+ + get_code(Colors.Blue)
+ + 'eee'
+ + get_code(None)
+ + 'fff'
+ ) == highlight_string(text, *spanlists, colors=colors)
+
def test_colorize():
assert (