Skip to content

Commit

Permalink
Rework RectangleF.Contains to not do equality comparison on floating …
Browse files Browse the repository at this point in the history
…point values. Fixes mono#5985.
  • Loading branch information
rolfbjarne committed Jul 5, 2012
1 parent 667e99b commit 53f463e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mcs/class/System.Drawing/System.Drawing/RectangleF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public bool Contains (PointF pt)

public bool Contains (RectangleF rect)
{
return (rect == Intersect (this, rect));
return X <= rect.X && Right >= rect.Right && Y <= rect.Y && Bottom >= rect.Bottom;
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions mcs/class/System.Drawing/Test/System.Drawing/TestRectangleF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public void Contains ()
Assert.IsFalse (rect_0.Contains (50, 10), "g");
}

[Test]
public void ContainsF ()
{
// from bug #5985
RectangleF outer = new RectangleF (100, 150, 300, 300);
RectangleF inner = new RectangleF (139.3323f, 188.4053f, 140.2086f, 210.3129f);

Assert.IsTrue (outer.Contains (inner), "a");
}

[Test]
public void Empty ()
{
Expand Down

0 comments on commit 53f463e

Please sign in to comment.