Refactoring IsTypeSupport to deal with save.

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
Yoan Blanc 2016-11-14 20:10:54 +01:00
parent dcd91c85e0
commit a2ba03da29
No known key found for this signature in database
GPG key ID: 6058CF4574298812
4 changed files with 86 additions and 24 deletions

View file

@ -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)
}
}
}