Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions color/color_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,32 @@ func TestColorString(t *testing.T) {
t.Errorf("wrong string for red: %q", s)
}
}

// TestColorNameAliases verifies that colors with more than one W3C name
// (e.g. "gray" and "grey") always report the same name.
func TestColorNameAliases(t *testing.T) {
cases := []struct {
c Color
name string
}{
{Gray, "gray"},
{DarkGray, "darkgray"},
{DarkSlateGray, "darkslategray"},
{DimGray, "dimgray"},
{LightGray, "lightgray"},
{LightSlateGray, "lightslategray"},
{SlateGray, "slategray"},
}
for _, cs := range cases {
t.Run(cs.name, func(t *testing.T) {
for i := 0; i < 200; i++ {
if got := cs.c.Name(); got != cs.name {
t.Fatalf("iteration %d: Name() = %q, want %q", i, got, cs.name)
}
if got := cs.c.String(); got != cs.name {
t.Fatalf("iteration %d: String() = %q, want %q", i, got, cs.name)
}
}
})
}
}
Loading