diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-05-12 23:56:07 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-05-12 23:56:07 -0400 |
commit | 38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8 (patch) | |
tree | a4fde09672192b97d453ad605b030bd5a10c5a45 /vendor/github.com/disintegration/imaging/transform_test.go | |
parent | 84d2482ddbff9564c9ad75b2d30af66e3ddfd44d (diff) | |
download | chat-38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8.tar.gz chat-38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8.tar.bz2 chat-38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8.zip |
Moving to glide
Diffstat (limited to 'vendor/github.com/disintegration/imaging/transform_test.go')
-rw-r--r-- | vendor/github.com/disintegration/imaging/transform_test.go | 261 |
1 files changed, 261 insertions, 0 deletions
diff --git a/vendor/github.com/disintegration/imaging/transform_test.go b/vendor/github.com/disintegration/imaging/transform_test.go new file mode 100644 index 000000000..6e64082f4 --- /dev/null +++ b/vendor/github.com/disintegration/imaging/transform_test.go @@ -0,0 +1,261 @@ +package imaging + +import ( + "image" + "testing" +) + +func TestRotate90(t *testing.T) { + td := []struct { + desc string + src image.Image + want *image.NRGBA + }{ + { + "Rotate90 2x3", + &image.NRGBA{ + Rect: image.Rect(-1, -1, 1, 2), + Stride: 2 * 4, + Pix: []uint8{ + 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, + }, + }, + &image.NRGBA{ + Rect: image.Rect(0, 0, 3, 2), + Stride: 3 * 4, + Pix: []uint8{ + 0xcc, 0xdd, 0xee, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0x00, 0x11, 0x22, 0x33, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, + }, + }, + }, + } + for _, d := range td { + got := Rotate90(d.src) + want := d.want + if !compareNRGBA(got, want, 0) { + t.Errorf("test [%s] failed: %#v", d.desc, got) + } + } +} + +func TestRotate180(t *testing.T) { + td := []struct { + desc string + src image.Image + want *image.NRGBA + }{ + { + "Rotate180 2x3", + &image.NRGBA{ + Rect: image.Rect(-1, -1, 1, 2), + Stride: 2 * 4, + Pix: []uint8{ + 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, + }, + }, + &image.NRGBA{ + Rect: image.Rect(0, 0, 2, 3), + Stride: 2 * 4, + Pix: []uint8{ + 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, + 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, + 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33, + }, + }, + }, + } + for _, d := range td { + got := Rotate180(d.src) + want := d.want + if !compareNRGBA(got, want, 0) { + t.Errorf("test [%s] failed: %#v", d.desc, got) + } + } +} + +func TestRotate270(t *testing.T) { + td := []struct { + desc string + src image.Image + want *image.NRGBA + }{ + { + "Rotate270 2x3", + &image.NRGBA{ + Rect: image.Rect(-1, -1, 1, 2), + Stride: 2 * 4, + Pix: []uint8{ + 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, + }, + }, + &image.NRGBA{ + Rect: image.Rect(0, 0, 3, 2), + Stride: 3 * 4, + Pix: []uint8{ + 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33, + 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xcc, 0xdd, 0xee, 0xff, + }, + }, + }, + } + for _, d := range td { + got := Rotate270(d.src) + want := d.want + if !compareNRGBA(got, want, 0) { + t.Errorf("test [%s] failed: %#v", d.desc, got) + } + } +} + +func TestFlipV(t *testing.T) { + td := []struct { + desc string + src image.Image + want *image.NRGBA + }{ + { + "FlipV 2x3", + &image.NRGBA{ + Rect: image.Rect(-1, -1, 1, 2), + Stride: 2 * 4, + Pix: []uint8{ + 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, + }, + }, + &image.NRGBA{ + Rect: image.Rect(0, 0, 2, 3), + Stride: 2 * 4, + Pix: []uint8{ + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff, + }, + }, + }, + } + for _, d := range td { + got := FlipV(d.src) + want := d.want + if !compareNRGBA(got, want, 0) { + t.Errorf("test [%s] failed: %#v", d.desc, got) + } + } +} + +func TestFlipH(t *testing.T) { + td := []struct { + desc string + src image.Image + want *image.NRGBA + }{ + { + "FlipH 2x3", + &image.NRGBA{ + Rect: image.Rect(-1, -1, 1, 2), + Stride: 2 * 4, + Pix: []uint8{ + 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, + }, + }, + &image.NRGBA{ + Rect: image.Rect(0, 0, 2, 3), + Stride: 2 * 4, + Pix: []uint8{ + 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33, + 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, + }, + }, + }, + } + for _, d := range td { + got := FlipH(d.src) + want := d.want + if !compareNRGBA(got, want, 0) { + t.Errorf("test [%s] failed: %#v", d.desc, got) + } + } +} + +func TestTranspose(t *testing.T) { + td := []struct { + desc string + src image.Image + want *image.NRGBA + }{ + { + "Transpose 2x3", + &image.NRGBA{ + Rect: image.Rect(-1, -1, 1, 2), + Stride: 2 * 4, + Pix: []uint8{ + 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, + }, + }, + &image.NRGBA{ + Rect: image.Rect(0, 0, 3, 2), + Stride: 3 * 4, + Pix: []uint8{ + 0x00, 0x11, 0x22, 0x33, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, + 0xcc, 0xdd, 0xee, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + }, + }, + }, + } + for _, d := range td { + got := Transpose(d.src) + want := d.want + if !compareNRGBA(got, want, 0) { + t.Errorf("test [%s] failed: %#v", d.desc, got) + } + } +} + +func TestTransverse(t *testing.T) { + td := []struct { + desc string + src image.Image + want *image.NRGBA + }{ + { + "Transverse 2x3", + &image.NRGBA{ + Rect: image.Rect(-1, -1, 1, 2), + Stride: 2 * 4, + Pix: []uint8{ + 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, + }, + }, + &image.NRGBA{ + Rect: image.Rect(0, 0, 3, 2), + Stride: 3 * 4, + Pix: []uint8{ + 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xcc, 0xdd, 0xee, 0xff, + 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33, + }, + }, + }, + } + for _, d := range td { + got := Transverse(d.src) + want := d.want + if !compareNRGBA(got, want, 0) { + t.Errorf("test [%s] failed: %#v", d.desc, got) + } + } +} |