-
Notifications
You must be signed in to change notification settings - Fork 3
/
response_test.go
63 lines (54 loc) · 1.19 KB
/
response_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
52
53
54
55
56
57
58
59
60
61
62
63
package epaper
import (
"errors"
"testing"
)
func TestOK(t *testing.T) {
err := wantOK("OK", nil)
if err != nil {
t.Errorf("OK resulted in error: %v", err)
}
err = wantOK("TEST", nil)
if err == nil {
t.Error("not OK input produced no error")
}
e := errors.New("")
err = wantOK("OK", e)
if err != e {
t.Error("error should have been forwarded")
}
}
func TestError(t *testing.T) {
testMap := map[string]error{
"Error:0": ErrInvalidCommand,
"Error:4": ErrFileNotFound,
"Error:250": ErrUndefined,
"Error:123": ErrUnknown,
}
for input, want := range testMap {
got := parseError(input)
if got != want {
t.Errorf("want %v, got %v", want, got)
}
}
}
func TestFontSize(t *testing.T) {
s, _ := parseFontSize("1", nil)
if s != FontSize32 {
t.Errorf("want FontSize32, got %v", s)
}
_, err := parseFontSize("0", nil)
if err == nil {
t.Error("expected error for invalid input")
}
}
func TestColors(t *testing.T) {
f, b, _ := parseColors("12", nil)
if f != ColorDarkGray || b != ColorLightGray {
t.Errorf("want ColorLightGray, ColorDarkGray, got %v, %v", f, b)
}
_, _, err := parseColors("12345", nil)
if err == nil {
t.Error("expected error for invalid input")
}
}