-
Notifications
You must be signed in to change notification settings - Fork 17
/
fonts_test.go
45 lines (38 loc) · 1.23 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
package lookup
import (
_ "image/png"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestFontSymbol(t *testing.T) {
Convey("When I create a fontSymbol from a image dile", t, func() {
img := loadImageGray("testdata/font_1/0.png")
fs := newFontSymbol("0", img)
Convey("It loads the image as a imageBinary", func() {
So(fs.image, ShouldHaveSameTypeAs, &imageBinary{})
So(fs.image.width, ShouldEqual, img.Bounds().Max.X)
So(fs.image.height, ShouldEqual, img.Bounds().Max.Y)
So(fs.symbol, ShouldEqual, "0")
So(fs.width, ShouldEqual, img.Bounds().Max.X)
So(fs.height, ShouldEqual, img.Bounds().Max.Y)
})
})
}
func TestLoadFont(t *testing.T) {
Convey("Given a font directory", t, func() {
Convey("When loading the symbols", func() {
fonts, _ := loadFont("testdata/font_1")
Convey("It loads all font files", func() {
So(len(fonts), ShouldEqual, 13)
})
Convey("It loads all symbol names correctly", func() {
var expectedNames = []string{"/", "€", "€", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
var actualNames []string
for _, f := range fonts {
actualNames = append(actualNames, f.symbol)
}
So(actualNames, ShouldResemble, expectedNames)
})
})
})
}