update: improve coverage
This commit is contained in:
parent
fdf3057743
commit
d0ec38c405
|
@ -7,6 +7,7 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewCaptcha(t *testing.T) {
|
func TestNewCaptcha(t *testing.T) {
|
||||||
|
@ -62,6 +63,18 @@ func TestCovNilFontError(t *testing.T) {
|
||||||
ttfFont = temp
|
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) {
|
func TestLoadFont(t *testing.T) {
|
||||||
err := LoadFont(goregular.TTF)
|
err := LoadFont(goregular.TTF)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Reference in New Issue