v4/utils/colors_test.go
2025-04-05 22:02:17 -07:00

29 lines
684 B
Go

package utils_test
import (
"testing"
"git.sapphic.engineer/roleypoly/v4/utils"
"github.com/stretchr/testify/assert"
)
func TestIntToRgb(t *testing.T) {
r, g, b := utils.IntToRgb(0x123456)
assert.Equal(t, uint8(0x12), r, "red")
assert.Equal(t, uint8(0x34), g, "green")
assert.Equal(t, uint8(0x56), b, "blue")
}
func TestIsDarkColor(t *testing.T) {
isDark := utils.IsDarkColor(0, 0, 0)
assert.True(t, isDark)
isLight := utils.IsDarkColor(255, 255, 255)
assert.False(t, isLight)
isQuestionable := utils.IsDarkColor(0x88, 0x88, 0x88)
assert.False(t, isQuestionable)
isReallyQuestionable := utils.IsDarkColor(0x00, 0x88, 0x00)
assert.True(t, isReallyQuestionable)
}