6 "github.com/stretchr/testify/assert"
7 "github.com/zyedidia/tcell"
10 func TestSimpleStringToStyle(t *testing.T) {
11 s := StringToStyle("lightblue,magenta")
13 fg, bg, _ := s.Decompose()
15 assert.Equal(t, tcell.ColorBlue, fg)
16 assert.Equal(t, tcell.ColorPurple, bg)
19 func TestAttributeStringToStyle(t *testing.T) {
20 s := StringToStyle("bold cyan,brightcyan")
22 fg, bg, attr := s.Decompose()
24 assert.Equal(t, tcell.ColorTeal, fg)
25 assert.Equal(t, tcell.ColorAqua, bg)
26 assert.NotEqual(t, 0, attr&tcell.AttrBold)
29 func TestColor256StringToStyle(t *testing.T) {
30 s := StringToStyle("128,60")
32 fg, bg, _ := s.Decompose()
34 assert.Equal(t, tcell.Color128, fg)
35 assert.Equal(t, tcell.Color60, bg)
38 func TestColorHexStringToStyle(t *testing.T) {
39 s := StringToStyle("#deadbe,#ef1234")
41 fg, bg, _ := s.Decompose()
43 assert.Equal(t, tcell.NewRGBColor(222, 173, 190), fg)
44 assert.Equal(t, tcell.NewRGBColor(239, 18, 52), bg)
47 func TestColorschemeParser(t *testing.T) {
48 testColorscheme := `color-link default "#F8F8F2,#282828"
49 color-link comment "#75715E,#282828"
51 color-link identifier "#66D9EF,#282828" #comment
52 color-link constant "#AE81FF,#282828"
53 color-link constant.string "#E6DB74,#282828"
54 color-link constant.string.char "#BDE6AD,#282828"`
56 c, err := ParseColorscheme(testColorscheme)
59 fg, bg, _ := c["comment"].Decompose()
60 assert.Equal(t, tcell.NewRGBColor(117, 113, 94), fg)
61 assert.Equal(t, tcell.NewRGBColor(40, 40, 40), bg)