package color_test import ( "io" "testing" "git.akyoto.dev/go/assert" "git.akyoto.dev/go/color" ) func TestColors(t *testing.T) { color.Terminal = true testColors(t) } func TestNoColors(t *testing.T) { color.Terminal = false testColors(t) } func testColors(t *testing.T) { colors := map[string]color.Color{ "black": color.RGB(0.0, 0.0, 0.0), "white": color.RGB(1.0, 1.0, 1.0), "red": color.RGB(1.0, 0.0, 0.0), "green": color.RGB(0.0, 1.0, 0.0), "blue": color.RGB(0.0, 0.0, 1.0), } for name, value := range colors { assert.True(t, value.R >= 0.0) assert.True(t, value.G >= 0.0) assert.True(t, value.B >= 0.0) assert.True(t, value.R <= 1.0) assert.True(t, value.G <= 1.0) assert.True(t, value.B <= 1.0) value.Fprint(io.Discard, name) value.Print(name) value.Println(name) } }