-
Notifications
You must be signed in to change notification settings - Fork 273
/
fonts_test.go
52 lines (44 loc) · 1.14 KB
/
fonts_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
package base64Captcha
import (
"testing"
)
// sources:
// fonts/3Dumb.ttf (142.224kB)
// fonts/ApothecaryFont.ttf (62.08kB)
// fonts/Comismsh.ttf (80.132kB)
// fonts/DENNEthree-dee.ttf (83.188kB)
// fonts/DeborahFancyDress.ttf (32.52kB)
// fonts/Flim-Flam.ttf (140.576kB)
// fonts/RitaSmith.ttf (31.24kB)
// fonts/actionj.ttf (34.944kB)
// fonts/chromohv.ttf (45.9kB)
// fonts/readme.md (162B)
// fonts/wqy-microhei.ttc (5.177MB)
func Test_loadFontByName(t *testing.T) {
f := DefaultEmbeddedFonts.LoadFontByName("fonts/wqy-microhei.ttc")
if f == nil {
t.Error("failed")
}
defer recoverPanic(t)
f = DefaultEmbeddedFonts.LoadFontByName("fonts/readme.md")
}
func recoverPanic(t *testing.T) {
r := recover()
if r == nil {
t.Error("not trigger panic")
}
}
func Test_loadFontsByNames(t *testing.T) {
fs := DefaultEmbeddedFonts.LoadFontsByNames([]string{"fonts/chromohv.ttf", "fonts/RitaSmith.ttf"})
if len(fs) != 2 {
t.Error("failed")
}
defer recoverPanic(t)
DefaultEmbeddedFonts.LoadFontsByNames([]string{"fonts/actionj.txxxxxtf"})
}
func Test_randFontFrom(t *testing.T) {
f := randFontFrom(fontsAll)
if f == nil {
t.Error("failed")
}
}