### Eclipse Workspace Patch 1.0 #P org.eclipse.draw2d.test Index: src/org/eclipse/draw2d/test/Draw2dTestSuite.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.gef/test/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/Draw2dTestSuite.java,v retrieving revision 1.19 diff -u -r1.19 Draw2dTestSuite.java --- src/org/eclipse/draw2d/test/Draw2dTestSuite.java 8 Aug 2008 15:08:50 -0000 1.19 +++ src/org/eclipse/draw2d/test/Draw2dTestSuite.java 4 Sep 2008 21:21:45 -0000 @@ -49,6 +49,7 @@ addTest(new TestSuite(FigureUtilitiesTest.class)); addTest(new TestSuite(RectangleTest.class)); // addTest(new TestSuite(ColorConstantTest.class)); + addTest(new TestSuite(RayTest.class)); } } Index: src/org/eclipse/draw2d/test/RayTest.java =================================================================== RCS file: src/org/eclipse/draw2d/test/RayTest.java diff -N src/org/eclipse/draw2d/test/RayTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/draw2d/test/RayTest.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.draw2d.test; + +import junit.framework.TestCase; + +import org.eclipse.draw2d.geometry.Ray; + +/** + * Ray's tests + * + * @author aboyko + * + */ +public class RayTest extends TestCase { + + /** + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + } + + /** + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void test_length() { + testLengthValues(3, 4, 5); + testLengthValues(0, Integer.MAX_VALUE, Integer.MAX_VALUE); + } + + private void testLengthValues(int x, int y, double expectedLength) { + Ray ray = new Ray(x, y); + assertEquals(expectedLength, ray.length(), 0); + } +} #P org.eclipse.draw2d Index: src/org/eclipse/draw2d/geometry/Ray.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Ray.java,v retrieving revision 1.10 diff -u -r1.10 Ray.java --- src/org/eclipse/draw2d/geometry/Ray.java 30 Mar 2005 21:27:45 -0000 1.10 +++ src/org/eclipse/draw2d/geometry/Ray.java 4 Sep 2008 21:21:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -160,7 +160,7 @@ * @since 2.0 */ public double length() { - return Math.sqrt(dotProduct(this)); + return Math.sqrt((long) x * x + (long) y * y); } /**