forked from lightningnetwork/lnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_test.go
36 lines (30 loc) · 828 Bytes
/
server_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
// +build !rpctest
package main
import "testing"
func TestParseHexColor(t *testing.T) {
empty := ""
color, err := parseHexColor(empty)
if err == nil {
t.Fatalf("Empty color string should return error, but did not")
}
tooLong := "#1234567"
color, err = parseHexColor(tooLong)
if err == nil {
t.Fatalf("Invalid color string %s should return error, but did not",
tooLong)
}
invalidFormat := "$123456"
color, err = parseHexColor(invalidFormat)
if err == nil {
t.Fatalf("Invalid color string %s should return error, but did not",
invalidFormat)
}
valid := "#C0FfeE"
color, err = parseHexColor(valid)
if err != nil {
t.Fatalf("Color %s valid to parse: %s", valid, err)
}
if color.R != 0xc0 || color.G != 0xff || color.B != 0xee {
t.Fatalf("Color %s incorrectly parsed as %v", valid, color)
}
}