6 "github.com/stretchr/testify/assert"
7 "github.com/zyedidia/tcell/v2"
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 TestMultiAttributesStringToStyle(t *testing.T) {
30 s := StringToStyle("bold italic underline cyan,brightcyan")
32 fg, bg, attr := s.Decompose()
34 assert.Equal(t, tcell.ColorTeal, fg)
35 assert.Equal(t, tcell.ColorAqua, bg)
36 assert.NotEqual(t, 0, attr&tcell.AttrBold)
37 assert.NotEqual(t, 0, attr&tcell.AttrItalic)
38 assert.NotEqual(t, 0, attr&tcell.AttrUnderline)
41 func TestColor256StringToStyle(t *testing.T) {
42 s := StringToStyle("128,60")
44 fg, bg, _ := s.Decompose()
46 assert.Equal(t, tcell.Color128, fg)
47 assert.Equal(t, tcell.Color60, bg)
50 func TestColorHexStringToStyle(t *testing.T) {
51 s := StringToStyle("#deadbe,#ef1234")
53 fg, bg, _ := s.Decompose()
55 assert.Equal(t, tcell.NewRGBColor(222, 173, 190), fg)
56 assert.Equal(t, tcell.NewRGBColor(239, 18, 52), bg)
59 func TestColorschemeParser(t *testing.T) {
60 testColorscheme := `color-link default "#F8F8F2,#282828"
61 color-link comment "#75715E,#282828"
63 color-link identifier "#66D9EF,#282828" #comment
64 color-link constant "#AE81FF,#282828"
65 color-link constant.string "#E6DB74,#282828"
66 color-link constant.string.char "#BDE6AD,#282828"`
68 c, err := ParseColorscheme(testColorscheme)
71 fg, bg, _ := c["comment"].Decompose()
72 assert.Equal(t, tcell.NewRGBColor(117, 113, 94), fg)
73 assert.Equal(t, tcell.NewRGBColor(40, 40, 40), bg)