summaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/thumbnail_test.go
blob: d12659f17d847e4bddfeba855354ed1b8d3ad427 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2011 The Graphics-Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package graphics

import (
	"code.google.com/p/graphics-go/graphics/graphicstest"
	"image"
	"testing"

	_ "image/png"
)

func TestThumbnailGopher(t *testing.T) {
	dst := image.NewRGBA(image.Rect(0, 0, 80, 80))

	src, err := graphicstest.LoadImage("../testdata/gopher.png")
	if err != nil {
		t.Fatal(err)
	}
	if err := Thumbnail(dst, src); err != nil {
		t.Fatal(err)
	}
	cmp, err := graphicstest.LoadImage("../testdata/gopher-thumb-80x80.png")
	if err != nil {
		t.Fatal(err)
	}
	err = graphicstest.ImageWithinTolerance(dst, cmp, 0)
	if err != nil {
		t.Error(err)
	}
}

func TestThumbnailLongGopher(t *testing.T) {
	dst := image.NewRGBA(image.Rect(0, 0, 50, 150))

	src, err := graphicstest.LoadImage("../testdata/gopher.png")
	if err != nil {
		t.Fatal(err)
	}
	if err := Thumbnail(dst, src); err != nil {
		t.Fatal(err)
	}
	cmp, err := graphicstest.LoadImage("../testdata/gopher-thumb-50x150.png")
	if err != nil {
		t.Fatal(err)
	}
	err = graphicstest.ImageWithinTolerance(dst, cmp, 0)
	if err != nil {
		t.Error(err)
	}
}