Add golden tests for Thumbnail

This commit is contained in:
Charlie Collard
2018-12-29 00:08:13 +00:00
parent 4ae66ee569
commit 26f8037242
5 changed files with 18 additions and 0 deletions

View File

@@ -630,6 +630,24 @@ func TestThumbnail(t *testing.T) {
}
}
func TestThumbnailGolden(t *testing.T) {
for name, filter := range map[string]ResampleFilter{
"out_thumbnail_nearest.png": NearestNeighbor,
"out_thumbnail_linear.png": Linear,
"out_thumbnail_catrom.png": CatmullRom,
"out_thumbnail_lanczos.png": Lanczos,
} {
got := Thumbnail(testdataBranchesPNG, 150, 100, filter)
want, err := Open("testdata/" + name)
if err != nil {
t.Fatalf("failed to open image: %v", err)
}
if !compareNRGBA(got, toNRGBA(want), 0) {
t.Fatalf("resulting image differs from golden: %s", name)
}
}
}
func BenchmarkResize(b *testing.B) {
for _, dir := range []string{"Down", "Up"} {
for _, filter := range []string{"NearestNeighbor", "Linear", "CatmullRom", "Lanczos"} {

BIN
testdata/out_thumbnail_catrom.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
testdata/out_thumbnail_lanczos.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
testdata/out_thumbnail_linear.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
testdata/out_thumbnail_nearest.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB