-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutil_test.go
34 lines (28 loc) · 1.17 KB
/
util_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package image2tiles_test
import (
"testing"
"github.com/lvisei/image2tiles"
"github.com/stretchr/testify/assert"
)
// TestLoadImage test open different type image file
func TestLoadImage(t *testing.T) {
assertions := assert.New(t)
jpgFilename := "testdata/earth_5568_3712.jpg"
openedImage, err := image2tiles.LoadImage(jpgFilename)
assertions.True(err == nil, "jpg image format should be supported")
assertions.True(openedImage != nil, "opened jpg file should not be nil")
pngFilename := "testdata/spongebob_698_530.png"
openedImage, err = image2tiles.LoadImage(pngFilename)
assertions.True(err == nil, "png image format should be supported")
assertions.True(openedImage != nil, "opened jpg file should not be nil")
notSupported := "testdata/not_supported_sample_image"
openedImage, err = image2tiles.LoadImage(notSupported)
assertions.True(err != nil, "should not open unsupported image")
assertions.True(openedImage == nil, "not supported image should be nil")
}
// TestLoadImageNotExistsFile test open a not exists file
func TestLoadImageNotExistsFile(t *testing.T) {
assertions := assert.New(t)
_, err := image2tiles.LoadImage("not exists")
assertions.True(err != nil)
}