63 lines
863 B
Go
63 lines
863 B
Go
package colors
|
|
|
|
import (
|
|
"image/color"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestFromInt(t *testing.T) {
|
|
type args struct {
|
|
in int32
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want color.Color
|
|
}{
|
|
{
|
|
name: "black",
|
|
args: args{
|
|
in: 0x000000,
|
|
},
|
|
want: color.RGBA{
|
|
0, 0, 0, 0xff,
|
|
},
|
|
},
|
|
{
|
|
name: "red",
|
|
args: args{
|
|
in: 0xff0000,
|
|
},
|
|
want: color.RGBA{
|
|
0xff, 0, 0, 0xff,
|
|
},
|
|
},
|
|
{
|
|
name: "green",
|
|
args: args{
|
|
in: 0x00ff00,
|
|
},
|
|
want: color.RGBA{
|
|
0, 0xff, 0, 0xff,
|
|
},
|
|
},
|
|
{
|
|
name: "blue",
|
|
args: args{
|
|
in: 0x0000ff,
|
|
},
|
|
want: color.RGBA{
|
|
0, 0, 0xff, 0xff,
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := FromInt(tt.args.in); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("FromInt() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|