summaryrefslogtreecommitdiffstats
path: root/tests/test_vt100_output.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_vt100_output.py')
-rw-r--r--tests/test_vt100_output.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_vt100_output.py b/tests/test_vt100_output.py
new file mode 100644
index 0000000..65c8377
--- /dev/null
+++ b/tests/test_vt100_output.py
@@ -0,0 +1,20 @@
+from __future__ import annotations
+
+from prompt_toolkit.output.vt100 import _get_closest_ansi_color
+
+
+def test_get_closest_ansi_color():
+ # White
+ assert _get_closest_ansi_color(255, 255, 255) == "ansiwhite"
+ assert _get_closest_ansi_color(250, 250, 250) == "ansiwhite"
+
+ # Black
+ assert _get_closest_ansi_color(0, 0, 0) == "ansiblack"
+ assert _get_closest_ansi_color(5, 5, 5) == "ansiblack"
+
+ # Green
+ assert _get_closest_ansi_color(0, 255, 0) == "ansibrightgreen"
+ assert _get_closest_ansi_color(10, 255, 0) == "ansibrightgreen"
+ assert _get_closest_ansi_color(0, 255, 10) == "ansibrightgreen"
+
+ assert _get_closest_ansi_color(220, 220, 100) == "ansiyellow"