update: do not panic in init function parse fail
update: extract test for small image from TestNewCaptcha fix: typo in test
This commit is contained in:
parent
21cc8dcbcb
commit
66c7cdc2f4
|
@ -71,11 +71,7 @@ func (data *Data) WriteTo(w io.Writer) error {
|
|||
}
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
ttfFont, err = freetype.ParseFont(ttf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ttfFont, _ = freetype.ParseFont(ttf)
|
||||
}
|
||||
|
||||
// LoadFont let you load an external font
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
)
|
||||
|
||||
func TestNewCaptcha(t *testing.T) {
|
||||
New(36, 12)
|
||||
data, err := New(150, 50)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -17,6 +16,13 @@ func TestNewCaptcha(t *testing.T) {
|
|||
data.WriteTo(buf)
|
||||
}
|
||||
|
||||
func TestSmallCaptcha(t *testing.T) {
|
||||
_, err := New(36, 12)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewCaptchaOptions(t *testing.T) {
|
||||
New(100, 34, func(options *Options) {
|
||||
options.BackgroundColor = color.Opaque
|
||||
|
@ -46,6 +52,6 @@ func TestLoadFont(t *testing.T) {
|
|||
|
||||
err = LoadFont([]byte("invalid"))
|
||||
if err == nil {
|
||||
t.Fatal("LoadFont incorrecly parse an invalid font")
|
||||
t.Fatal("LoadFont incorrectly parse an invalid font")
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue