2023-12-19 10:47:40 +03:00
|
|
|
package twin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestColorRgbFirst16(t *testing.T) {
|
|
|
|
r, g, b := color256ToRGB(5)
|
|
|
|
|
2023-12-20 20:28:07 +03:00
|
|
|
assert.Equal(t, r, uint8(0x80))
|
|
|
|
assert.Equal(t, g, uint8(0x00))
|
|
|
|
assert.Equal(t, b, uint8(0x80))
|
2023-12-19 10:47:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestColorToRgbInTheGrey(t *testing.T) {
|
|
|
|
r, g, b := color256ToRGB(252)
|
|
|
|
|
2023-12-20 20:28:07 +03:00
|
|
|
assert.Equal(t, r, uint8(0xd0))
|
|
|
|
assert.Equal(t, g, uint8(0xd0))
|
|
|
|
assert.Equal(t, b, uint8(0xd0))
|
2023-12-19 10:47:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestColorToRgbInThe6x6Cube(t *testing.T) {
|
|
|
|
r, g, b := color256ToRGB(101)
|
|
|
|
|
2023-12-20 20:28:07 +03:00
|
|
|
assert.Equal(t, r, uint8(0x87))
|
|
|
|
assert.Equal(t, g, uint8(0x87))
|
|
|
|
assert.Equal(t, b, uint8(0x5f))
|
2023-12-19 10:47:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestColorToRgbStart6x6Cube(t *testing.T) {
|
|
|
|
r, g, b := color256ToRGB(16)
|
|
|
|
|
2023-12-20 20:28:07 +03:00
|
|
|
assert.Equal(t, r, uint8(0x00))
|
|
|
|
assert.Equal(t, g, uint8(0x00))
|
|
|
|
assert.Equal(t, b, uint8(0x00))
|
2023-12-19 10:47:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestColorRgbEnd6x6Cube(t *testing.T) {
|
|
|
|
r, g, b := color256ToRGB(231)
|
|
|
|
|
2023-12-20 20:28:07 +03:00
|
|
|
assert.Equal(t, r, uint8(0xff))
|
|
|
|
assert.Equal(t, g, uint8(0xff))
|
|
|
|
assert.Equal(t, b, uint8(0xff))
|
2023-12-19 10:47:40 +03:00
|
|
|
}
|