mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-26 16:03:10 +03:00
Switch to github.com/gookit/color for terminal colors
This commit is contained in:
63
pkg/utils/color_test.go
Normal file
63
pkg/utils/color_test.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetHexColorValues(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
name string
|
||||
hexColor string
|
||||
rgb []int32
|
||||
valid bool
|
||||
}{
|
||||
{
|
||||
name: "valid uppercase hex color",
|
||||
hexColor: "#00FF00",
|
||||
rgb: []int32{0, 255, 0},
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "valid lowercase hex color",
|
||||
hexColor: "#00ff00",
|
||||
rgb: []int32{0, 255, 0},
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "valid short hex color",
|
||||
hexColor: "#0bf",
|
||||
rgb: []int32{0, 187, 255},
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "invalid hex value",
|
||||
hexColor: "#zz00ff",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "invalid length hex color",
|
||||
hexColor: "#",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "invalid length hex color",
|
||||
hexColor: "#aaaaaaaaaaa",
|
||||
valid: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
s := s
|
||||
t.Run(s.name, func(t *testing.T) {
|
||||
r, g, b, valid := GetHexColorValues(s.hexColor)
|
||||
assert.EqualValues(t, s.valid, valid, s.hexColor)
|
||||
if valid {
|
||||
assert.EqualValues(t, s.rgb[0], r, s.hexColor)
|
||||
assert.EqualValues(t, s.rgb[1], g, s.hexColor)
|
||||
assert.EqualValues(t, s.rgb[2], b, s.hexColor)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user