summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Matusiak <numerodix@gmail.com>2021-05-05 12:29:47 +1000
committerMartin Matusiak <numerodix@gmail.com>2021-05-05 12:29:47 +1000
commit6fba7358f8fef9f48ff9c0936aa706c86cb6bd84 (patch)
tree0a63b826851d7debf8dc96b312a0471f9e141fbe
parent45637c18dd67a44a9ce82f22064ed4b3657f330c (diff)
downloadansicolor-6fba7358f8fef9f48ff9c0936aa706c86cb6bd84.tar.gz
add test for highlight_string
-rw-r--r--tests/test_colors.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_colors.py b/tests/test_colors.py
index 901f669..33a7adf 100644
--- a/tests/test_colors.py
+++ b/tests/test_colors.py
@@ -107,6 +107,41 @@ def test_get_hightlighter():
assert Colors.Yellow == get_highlighter(1)
+def test_highlight_string_four_layers():
+ text = "aaabbbcccdddeeefffeeedddcccbbbaaa"
+ spanlists = [
+ [(3, 30)],
+ [(6, 27)],
+ [(9, 24)],
+ [(12, 21)],
+ ]
+ colors = [
+ Colors.Green,
+ Colors.Yellow,
+ Colors.Cyan,
+ Colors.Blue,
+ ]
+
+ assert (
+ 'aaa'
+ + get_code(Colors.Green)
+ + 'bbb'
+ + get_code(Colors.Yellow, bold=True)
+ + 'ccc'
+ + get_code(Colors.Cyan, reverse=True)
+ + 'ddd'
+ + get_code(Colors.Blue, bold=True, reverse=True)
+ + 'eeefffeee'
+ + get_code(Colors.Cyan, reverse=True)
+ + 'ddd'
+ + get_code(Colors.Yellow, bold=True)
+ + 'ccc'
+ + get_code(Colors.Green)
+ + 'bbb'
+ + get_code(None)
+ + 'aaa'
+ ) == highlight_string(text, *spanlists, colors=colors)
+
def test_highlight_string__more_spans_than_colors():
first_highlighter = get_highlighter(0)
assert (