You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ap...@apache.org on 2006/11/07 14:52:53 UTC
svn commit: r472117 - in
/incubator/harmony/enhanced/classlib/trunk/modules/awt/src:
main/java/common/java/awt/Point.java
test/api/java/common/java/awt/PointTest.java
Author: apetrenko
Date: Tue Nov 7 05:52:53 2006
New Revision: 472117
URL: http://svn.apache.org/viewvc?view=rev&rev=472117
Log:
Patch for HARMONY-1878 "[classlib][awt] Point.setLocation(double, double) doesn't follow spec if x or y is larger/smaller than max/min integer value"
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Point.java
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PointTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Point.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Point.java?view=diff&rev=472117&r1=472116&r2=472117
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Point.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Point.java Tue Nov 7 05:52:53 2006
@@ -84,6 +84,8 @@
@Override
public void setLocation(double x, double y) {
+ x = x < Integer.MIN_VALUE ? Integer.MIN_VALUE : x > Integer.MAX_VALUE ? Integer.MAX_VALUE : x;
+ y = y < Integer.MIN_VALUE ? Integer.MIN_VALUE : y > Integer.MAX_VALUE ? Integer.MAX_VALUE : y;
setLocation((int)Math.round(x), (int)Math.round(y));
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PointTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PointTest.java?view=diff&rev=472117&r1=472116&r2=472117
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PointTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PointTest.java Tue Nov 7 05:52:53 2006
@@ -59,28 +59,52 @@
assertEquals(new Point(1, 2), new Point(1, 2).getLocation());
}
- public void testSetLocation1() {
+ public void testSetLocationInt() {
Point p = new Point(1, 2);
p.setLocation(3, 4);
assertEquals(new Point(3, 4), p);
}
- public void testSetLocation2() {
+ public void testSetLocationDouble1() {
Point p = new Point(1, 2);
p.setLocation(3.0, 4.0);
assertEquals(new Point(3, 4), p);
+ }
+
+ public void testSetLocationDouble2() {
+ Point p = new Point(1, 2);
p.setLocation(5.3, 6.7);
assertEquals(new Point(5, 7), p);
+ }
+
+ public void testSetLocationDouble3() {
+ Point p = new Point(1, 2);
p.setLocation(7.5, 8.5);
assertEquals(new Point(8, 9), p);
}
- public void testSetLocation3() {
+ public void testSetLocationDouble4() {
+ // Regression test HARMONY-1878
+ Point p = new Point(1, 2);
+ double x = (double)Integer.MAX_VALUE + (double)1;
+ double y = (double)Integer.MIN_VALUE - (double)1;
+ p.setLocation(x, y);
+ assertEquals(new Point(Integer.MAX_VALUE, Integer.MIN_VALUE), p);
+ }
+
+ public void testSetLocationDouble5() {
+ // Regression test HARMONY-1878
+ Point p = new Point(1, 2);
+ p.setLocation(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
+ assertEquals(new Point(Integer.MAX_VALUE, Integer.MIN_VALUE), p);
+ }
+
+ public void testSetLocationPoint() {
Point p = new Point(1, 2);
p.setLocation(new Point(3, 4));
assertEquals(new Point(3, 4), p);
}
-
+
public void testMove() {
Point p = new Point(1, 2);
p.move(3, 4);