mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-07 21:48:13 -08:00
Refactoring IsTypeSupport to deal with save.
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
parent
dcd91c85e0
commit
a2ba03da29
4 changed files with 86 additions and 24 deletions
41
type_test.go
41
type_test.go
|
|
@ -66,7 +66,7 @@ func TestIsTypeSupported(t *testing.T) {
|
|||
|
||||
for _, n := range types {
|
||||
if IsTypeSupported(n.name) == false {
|
||||
t.Fatal("Image type is not valid")
|
||||
t.Fatalf("Image type %#v is not valid", ImageTypes[n.name])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,7 +85,44 @@ func TestIsTypeNameSupported(t *testing.T) {
|
|||
|
||||
for _, n := range types {
|
||||
if IsTypeNameSupported(n.name) != n.expected {
|
||||
t.Fatal("Image type is not valid")
|
||||
t.Fatalf("Image type %#v is not valid", n.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsTypeSupportedSave(t *testing.T) {
|
||||
types := []struct {
|
||||
name ImageType
|
||||
}{
|
||||
{JPEG}, {PNG}, {WEBP},
|
||||
}
|
||||
if VipsVersion >= "8.5.0" {
|
||||
types = append(types, struct{ name ImageType }{TIFF})
|
||||
}
|
||||
|
||||
for _, n := range types {
|
||||
if IsTypeSupportedSave(n.name) == false {
|
||||
t.Fatalf("Image type %#v is not valid", ImageTypes[n.name])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsTypeNameSupportedSave(t *testing.T) {
|
||||
types := []struct {
|
||||
name string
|
||||
expected bool
|
||||
}{
|
||||
{"jpeg", true},
|
||||
{"png", true},
|
||||
{"webp", true},
|
||||
{"gif", false},
|
||||
{"pdf", false},
|
||||
{"tiff", VipsVersion >= "8.5.0"},
|
||||
}
|
||||
|
||||
for _, n := range types {
|
||||
if IsTypeNameSupportedSave(n.name) != n.expected {
|
||||
t.Fatalf("Image type %#v is not valid", n.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue