diff options
author | Jack <jackdeng@gmail.com> | 2015-09-22 08:16:51 -0700 |
---|---|---|
committer | Jack <jackdeng@gmail.com> | 2015-09-22 08:16:51 -0700 |
commit | 602bed85f2b32733f73e2edddb542fa36baac462 (patch) | |
tree | 06a6ee9b609a9122bc2f0e6f6e6300f9ba79a3aa /Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/rotate_test.go | |
parent | a31868336f97a91bfd5a7e91e99a9b294d131f90 (diff) | |
parent | f439c82d7c885b4c530ba9da0a41b17910743b55 (diff) | |
download | chat-602bed85f2b32733f73e2edddb542fa36baac462.tar.gz chat-602bed85f2b32733f73e2edddb542fa36baac462.tar.bz2 chat-602bed85f2b32733f73e2edddb542fa36baac462.zip |
fix conflict
Diffstat (limited to 'Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/rotate_test.go')
-rw-r--r-- | Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/rotate_test.go | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/rotate_test.go b/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/rotate_test.go new file mode 100644 index 000000000..bfc532a0a --- /dev/null +++ b/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/rotate_test.go @@ -0,0 +1,169 @@ +// 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" + "math" + "testing" + + _ "image/png" +) + +var rotateOneColorTests = []transformOneColorTest{ + { + "onepixel-onequarter", 1, 1, 1, 1, + &RotateOptions{math.Pi / 2}, + []uint8{0xff}, + []uint8{0xff}, + }, + { + "onepixel-partial", 1, 1, 1, 1, + &RotateOptions{math.Pi * 2.0 / 3.0}, + []uint8{0xff}, + []uint8{0xff}, + }, + { + "onepixel-complete", 1, 1, 1, 1, + &RotateOptions{2 * math.Pi}, + []uint8{0xff}, + []uint8{0xff}, + }, + { + "even-onequarter", 2, 2, 2, 2, + &RotateOptions{math.Pi / 2.0}, + []uint8{ + 0xff, 0x00, + 0x00, 0xff, + }, + []uint8{ + 0x00, 0xff, + 0xff, 0x00, + }, + }, + { + "even-complete", 2, 2, 2, 2, + &RotateOptions{2.0 * math.Pi}, + []uint8{ + 0xff, 0x00, + 0x00, 0xff, + }, + []uint8{ + 0xff, 0x00, + 0x00, 0xff, + }, + }, + { + "line-partial", 3, 3, 3, 3, + &RotateOptions{math.Pi * 1.0 / 3.0}, + []uint8{ + 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, + }, + []uint8{ + 0xa2, 0x80, 0x00, + 0x22, 0xff, 0x22, + 0x00, 0x80, 0xa2, + }, + }, + { + "line-offset-partial", 3, 3, 3, 3, + &RotateOptions{math.Pi * 3 / 2}, + []uint8{ + 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, + 0x00, 0x00, 0x00, + }, + []uint8{ + 0x00, 0xff, 0x00, + 0x00, 0xff, 0x00, + 0x00, 0x00, 0x00, + }, + }, + { + "dot-partial", 4, 4, 4, 4, + &RotateOptions{math.Pi}, + []uint8{ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }, + []uint8{ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, + }, + }, +} + +func TestRotateOneColor(t *testing.T) { + for _, oc := range rotateOneColorTests { + src := oc.newSrc() + dst := oc.newDst() + + if err := Rotate(dst, src, oc.opt.(*RotateOptions)); err != nil { + t.Errorf("rotate %s: %v", oc.desc, err) + continue + } + if !checkTransformTest(t, &oc, dst) { + continue + } + } +} + +func TestRotateEmpty(t *testing.T) { + empty := image.NewRGBA(image.Rect(0, 0, 0, 0)) + if err := Rotate(empty, empty, nil); err != nil { + t.Fatal(err) + } +} + +func TestRotateGopherSide(t *testing.T) { + src, err := graphicstest.LoadImage("../testdata/gopher.png") + if err != nil { + t.Fatal(err) + } + + srcb := src.Bounds() + dst := image.NewRGBA(image.Rect(0, 0, srcb.Dy(), srcb.Dx())) + if err := Rotate(dst, src, &RotateOptions{math.Pi / 2.0}); err != nil { + t.Fatal(err) + } + + cmp, err := graphicstest.LoadImage("../testdata/gopher-rotate-side.png") + if err != nil { + t.Fatal(err) + } + err = graphicstest.ImageWithinTolerance(dst, cmp, 0x101) + if err != nil { + t.Fatal(err) + } +} + +func TestRotateGopherPartial(t *testing.T) { + src, err := graphicstest.LoadImage("../testdata/gopher.png") + if err != nil { + t.Fatal(err) + } + + srcb := src.Bounds() + dst := image.NewRGBA(image.Rect(0, 0, srcb.Dx(), srcb.Dy())) + if err := Rotate(dst, src, &RotateOptions{math.Pi / 3.0}); err != nil { + t.Fatal(err) + } + + cmp, err := graphicstest.LoadImage("../testdata/gopher-rotate-partial.png") + if err != nil { + t.Fatal(err) + } + err = graphicstest.ImageWithinTolerance(dst, cmp, 0x101) + if err != nil { + t.Fatal(err) + } +} |