From ae274158de38181bca27f2ce54c8b4fc0b688eff Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 10 Jan 2017 02:16:12 +0900 Subject: Add experimental support for 24-bit colors --- src/tui/tui_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/tui/tui_test.go (limited to 'src/tui/tui_test.go') diff --git a/src/tui/tui_test.go b/src/tui/tui_test.go new file mode 100644 index 00000000..3ba9bf35 --- /dev/null +++ b/src/tui/tui_test.go @@ -0,0 +1,20 @@ +package tui + +import "testing" + +func TestHexToColor(t *testing.T) { + assert := func(expr string, r, g, b int) { + color := HexToColor(expr) + if !color.is24() || + int((color>>16)&0xff) != r || + int((color>>8)&0xff) != g || + int((color)&0xff) != b { + t.Fail() + } + } + + assert("#ff0000", 255, 0, 0) + assert("#010203", 1, 2, 3) + assert("#102030", 16, 32, 48) + assert("#ffffff", 255, 255, 255) +} -- cgit v1.2.3