-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathavatar_test.go
40 lines (36 loc) · 878 Bytes
/
avatar_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
package avatar
import "testing"
func TestCleanString(t *testing.T) {
// Input should equal output
tests := map[string]string{}
tests["AE"] = "AE"
tests["ae"] = "AE"
tests["a e"] = "AE"
tests["andrew edwards"] = "AE"
tests["andrew edwards"] = "AN"
tests["a"] = "A"
tests["123"] = "12"
tests["A 3"] = "A3"
tests["B 3"] = "B3"
for k, v := range tests {
if cleanString(k) != v {
t.Errorf("Received '%s', was expecting '%s' from '%s'", cleanString(k), v, k)
}
}
}
func TestGetFont(t *testing.T) {
f, err := getFont("rubbish")
if err == nil {
t.Error("should not have been able to return a font")
}
if f != nil {
t.Error("should not have been able to return a font")
}
f, err = getFont(defaultfontFace)
if err != nil {
t.Error("should of been able to return a font", err)
}
if f == nil {
t.Error("should of been able to return a font")
}
}