1
0
mirror of https://github.com/6543/go-hexcolor synced 2025-07-01 22:43:15 +00:00
go-hexcolor/hexcolor_test.go
6543 344c8d43be
Impruve docs (#7)
* Add Usage Example (close #4)

* Add Contribute Note (close #5)

* add godocs docu
2020-09-21 06:59:23 +02:00

37 lines
672 B
Go

// Copyright 2020 6543. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package hexcolor
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewHexColor(t *testing.T) {
cases := []struct {
color string
hex string
err bool
}{
{"#dd22cc", "dd22cc", false},
{"#adf", "aaddff", false},
{"15d", "1155dd", false},
{"a5i", "", true},
}
for _, tc := range cases {
hc, err := NewHexColor(tc.color)
if tc.err {
assert.Error(t, err)
} else {
assert.NoError(t, err)
if assert.NotNil(t, hc) {
assert.EqualValues(t, tc.hex, hc.hex)
}
}
}
}