|
@@ -187,3 +187,75 @@ func TestFlipH(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|