1
0
mirror of https://github.com/6543/go-hexcolor synced 2024-12-18 15:54:17 +00:00

better test

This commit is contained in:
6543 2020-09-10 17:52:52 +02:00
parent 7185dc6b49
commit 88c3f96e47
Signed by: 6543
GPG Key ID: A1CA74D27FD13271

View File

@ -20,13 +20,13 @@ func TestNewHexColor(t *testing.T) {


for _, tc := range cases { for _, tc := range cases {
hc, err := NewHexColor(tc.color) hc, err := NewHexColor(tc.color)
if tc.err && err == nil { if tc.err {
t.Fatalf("expected error for color: %q", tc.color) assert.Error(t, err)
} else if !tc.err && err != nil { } else {
t.Fatalf("error for color %q: %s", tc.color, err) assert.NoError(t, err)
}
if assert.NotNil(t, hc) { if assert.NotNil(t, hc) {
assert.EqualValues(t, tc.hex, hc.hex) assert.EqualValues(t, tc.hex, hc.hex)
} }
} }
}
} }