summaryrefslogtreecommitdiffstats
path: root/src/tui/tui_test.go
blob: 3ba9bf3569326e259e679f22d8a6c2a0f85cfcd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)
}