termstr: Coding style.

- Add tests for xterm_colors and closest_color_index.
This commit is contained in:
Andrew Hamilton 2021-11-11 17:22:07 +10:00
parent 2b5d14b87d
commit 33616d3f37

View file

@ -10,6 +10,23 @@ import fill3.terminal as terminal
import termstr
class XtermColorsTests(unittest.TestCase):
def test_xterm_colors(self):
self.assertEqual(len(termstr.XTERM_COLORS), 256)
self.assertEqual(termstr.XTERM_COLORS[0], (0, 0, 0))
self.assertEqual(termstr.XTERM_COLORS[100], (135, 135, 0))
self.assertEqual(termstr.XTERM_COLORS[255], (238, 238, 238))
def test_closest_color_index(self):
self.assertEqual(termstr.closest_color_index(
(0, 0, 0), termstr.XTERM_COLORS), 0)
self.assertEqual(termstr.closest_color_index(
(255, 255, 255), termstr.XTERM_COLORS), 15)
self.assertEqual(termstr.closest_color_index(
(135, 135, 1), termstr.XTERM_COLORS), 100)
class CharStyleTests(unittest.TestCase):
def setUp(self):