update: improve coverage

This commit is contained in:
Weilin Shi 2017-10-15 20:15:14 +08:00
parent fdf3057743
commit d0ec38c405
1 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"math/rand"
"os"
"testing"
"errors"
)
func TestNewCaptcha(t *testing.T) {
@ -62,6 +63,18 @@ func TestCovNilFontError(t *testing.T) {
ttfFont = temp
}
type errReader struct {}
func (errReader) Read(_ []byte) (int, error) {
return 0, errors.New("")
}
func TestCovReaderErr(t *testing.T) {
err := LoadFontFromReader(errReader{})
if err == nil {
t.Fatal("Expect to get io.Reader error")
}
}
func TestLoadFont(t *testing.T) {
err := LoadFont(goregular.TTF)
if err != nil {