mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 07:28:44 -07:00
Testing the formats that cannot be saved
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
parent
d37b4049d5
commit
b02f2d89cd
1 changed files with 28 additions and 7 deletions
35
vips_test.go
35
vips_test.go
|
|
@ -29,15 +29,36 @@ func TestVipsRead(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestVipsSave(t *testing.T) {
|
||||
image, _, _ := vipsRead(readImage("test.jpg"))
|
||||
options := vipsSaveOptions{Quality: 95, Type: JPEG, Interlace: true}
|
||||
types := [...]ImageType{JPEG, PNG, TIFF, WEBP}
|
||||
|
||||
buf, err := vipsSave(image, options)
|
||||
if err != nil {
|
||||
t.Fatal("Cannot save the image")
|
||||
for _, typ := range types {
|
||||
image, _, _ := vipsRead(readImage("test.jpg"))
|
||||
options := vipsSaveOptions{Quality: 95, Type: typ}
|
||||
|
||||
buf, err := vipsSave(image, options)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot save the image as '%v'", ImageTypes[typ])
|
||||
}
|
||||
if len(buf) == 0 {
|
||||
t.Fatalf("Empty saved '%v' image", ImageTypes[typ])
|
||||
}
|
||||
}
|
||||
if len(buf) == 0 {
|
||||
t.Fatal("Empty image")
|
||||
}
|
||||
|
||||
func TestVipsCannotSave(t *testing.T) {
|
||||
types := [...]ImageType{GIF, PDF, SVG, MAGICK}
|
||||
|
||||
for _, typ := range types {
|
||||
image, _, _ := vipsRead(readImage("test.jpg"))
|
||||
options := vipsSaveOptions{Quality: 95, Type: typ}
|
||||
|
||||
buf, err := vipsSave(image, options)
|
||||
if err == nil {
|
||||
t.Fatalf("Format '%v' shouldn't be supported", ImageTypes[typ])
|
||||
}
|
||||
if len(buf) != 0 {
|
||||
t.Fatalf("'%v' image is not empty", ImageTypes[typ])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue