-
Notifications
You must be signed in to change notification settings - Fork 0
/
format_test.go
51 lines (42 loc) · 859 Bytes
/
format_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package hexcolor
import (
"testing"
)
func TestFormat(t *testing.T) {
tests := []struct{
Red uint8
Green uint8
Blue uint8
Expected string
}{
{
Red: 0,
Green: 0,
Blue: 0,
Expected: "#000000",
},
{
Red: 1,
Green: 2,
Blue: 3,
Expected: "#010203",
},
{
Red: 0x1A,
Green: 0xB2,
Blue: 0x3C,
Expected: "#1AB23C",
},
}
for testNumber, test := range tests {
actual := Format(test.Red, test.Green, test.Blue)
expected := test.Expected
if expected != actual {
t.Errorf("For test #%d, the actual hex color code is not what was expected.", testNumber)
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
t.Logf("(R,G,B): (%02X,%02X,%02X)", test.Red, test.Green, test.Blue)
continue
}
}
}