New tests, update.
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / TestRectangleF.cs
index 2bdcc74ade07532151781093afedb5c45a45b94b..646c1ceb82c2ab45d948eae1665d4f3b796aca63 100644 (file)
@@ -84,6 +84,7 @@ namespace MonoTests.System.Drawing
                        Assert.IsTrue (rect_2.IsEmpty, "2");
                        Assert.IsTrue (rect_3.IsEmpty, "3");
                        Assert.IsTrue (rect_6.IsEmpty, "6");
+                       Assert.IsTrue (new RectangleF (0, 0, -1, -1).IsEmpty, "negative w/h");
                }
 
                [Test]
@@ -216,6 +217,40 @@ namespace MonoTests.System.Drawing
                        Assert.IsTrue (r0 != new RectangleF (1, 2, 0, 4), "Width");
                        Assert.IsTrue (r0 != new RectangleF (1, 2, 3, 0), "Height");
                }
+
+               [Test]
+               public void NegativeWidth ()
+               {
+                       RectangleF r = new RectangleF (0, 0, -1, 10);
+                       Assert.AreEqual (0, r.X, "X");
+                       Assert.AreEqual (0, r.Y, "Y");
+                       Assert.AreEqual (-1, r.Width, "Width");
+                       Assert.AreEqual (10, r.Height, "Height");
+               }
+
+               [Test]
+               public void NegativeHeight ()
+               {
+                       RectangleF r = new RectangleF (10, 10, 10, -1);
+                       Assert.AreEqual (10, r.X, "X");
+                       Assert.AreEqual (10, r.Y, "Y");
+                       Assert.AreEqual (10, r.Width, "Width");
+                       Assert.AreEqual (-1, r.Height, "Height");
+               }
+
+               [Test]
+               public void EdgeIntersection ()
+               {
+                       // https://bugzilla.novell.com/show_bug.cgi?id=431587
+                       RectangleF one = new RectangleF(10, 10, 10, 10);
+                       RectangleF two = new RectangleF(20, 10, 10, 10);
+
+                       one.Intersect(two);
+                       Assert.IsTrue (one.IsEmpty, "Empty");
+                       Assert.AreEqual (20f, one.X, "X");
+                       Assert.AreEqual (10f, one.Y, "Y");
+                       Assert.AreEqual (0f, one.Width, "Width");
+                       Assert.AreEqual (10f, one.Height, "Height");
+               }
        }
 }
-