Pārlūkot izejas kodu

add test case

Change-Id: I34f6e8ebe111d85a9631e710ad4180b73c8fc881
yefu 5 gadi atpakaļ
vecāks
revīzija
e413873b85
1 mainītis faili ar 53 papildinājumiem un 0 dzēšanām
  1. 53 0
      tools_test.go

+ 53 - 0
tools_test.go

@@ -328,6 +328,28 @@ func TestCrop(t *testing.T) {
 		r    image.Rectangle
 		want *image.NRGBA
 	}{
+		{
+			"Crop 2x3 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.Rect(-1, -1, 1, 2),
+			&image.NRGBA{
+				Rect:   image.Rect(0, 0, 2, 3),
+				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,
+				},
+			},
+		},
 		{
 			"Crop 2x3 2x1",
 			&image.NRGBA{
@@ -768,6 +790,37 @@ func TestPaste(t *testing.T) {
 		p    image.Point
 		want *image.NRGBA
 	}{
+		{
+			"Paste 2x3 2x3",
+			&image.NRGBA{
+				Rect:   image.Rect(0, 0, 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(-1, -1, 1, 2),
+				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,
+				},
+			},
+			image.Pt(0, 0),
+			&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,
+				},
+			},
+		},
 		{
 			"Paste 2x3 2x1",
 			&image.NRGBA{