This is the mail archive of the
mauve-patches@sources.redhat.com
mailing list for the Mauve project.
java.awt.geom.RectangularShape
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Mon, 06 Sep 2004 20:26:37 +0100
- Subject: java.awt.geom.RectangularShape
I've attached some tests for the java.awt.geom.RectangularShape base
class. All checks pass using JamVM 1.1.4 and JDK 1.4:
dgilbert@linux42:~/workspace/mauve> java -cp .
gnu.testlet.SimpleTestHarness -file RectangularShapeTests.txt -debug
0 of 486 tests failed
dgilbert@linux42:~/workspace/mauve> jamvm -cp .
gnu.testlet.SimpleTestHarness -file RectangularShapeTests.txt -debug
0 of 486 tests failed
Further tests for Rectangle2D coming soon...
Regards,
Dave Gilbert
www.jfree.org
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the contains() method in the {@link RectangularShape} class.
* Only the most general checks are performed here, more specific tests should
* be done at the level of the subclass.
*/
public class contains implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
// check null arguments
boolean pass = false;
try
{
r.contains((Point2D) null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
pass = false;
try
{
r.contains((Rectangle2D) null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the getBounds() method in the {@link RectangularShape} class.
* Only the most general checks are performed here, more specific tests should
* be done at the level of the subclass.
*/
public class getBounds implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
r.setFrame(0.0, 0.0, 0.0, 0.0);
Rectangle bounds = r.getBounds();
harness.check(bounds.x == 0);
harness.check(bounds.y == 0);
harness.check(bounds.width == 0);
harness.check(bounds.height == 0);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the getCenterX() method in the {@link RectangularShape} class.
*/
public class getCenterX implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
r.setFrame(1.0, 2.0, 3.0, 4.0);
harness.check(r.getCenterX(), 2.5);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// it is probably overkill to test all these subclasses, but
// anyway...
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the getCenterY() method in the {@link RectangularShape} class.
*/
public class getCenterY implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
r.setFrame(1.0, 2.0, 3.0, 4.0);
harness.check(r.getCenterY(), 4.0);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// it is probably overkill to test all these subclasses, but
// anyway...
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the getFrame() method in the {@link RectangularShape} class.
*/
public class getFrame implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
r.setFrame(1.0, 2.0, 3.0, 4.0);
Rectangle2D f = r.getFrame();
harness.check(f.getX(), 1.0);
harness.check(f.getY(), 2.0);
harness.check(f.getWidth(), 3.0);
harness.check(f.getHeight(), 4.0);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// it is probably overkill to test all these subclasses, but
// anyway...
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the getMaxX() method in the {@link RectangularShape} class.
*/
public class getMaxX implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
r.setFrame(1.0, 2.0, 3.0, 4.0);
harness.check(r.getMaxX(), 4.0);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// it is probably overkill to test all these subclasses, but
// anyway...
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the getMaxY() method in the {@link RectangularShape} class.
*/
public class getMaxY implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
r.setFrame(1.0, 2.0, 3.0, 4.0);
harness.check(r.getMaxY(), 6.0);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// it is probably overkill to test all these subclasses, but
// anyway...
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the getMinX() method in the {@link RectangularShape} class.
*/
public class getMinX implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
r.setFrame(1.0, 2.0, 3.0, 4.0);
harness.check(r.getMinX(), 1.0);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// it is probably overkill to test all these subclasses, but
// anyway...
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the getMinY() method in the {@link RectangularShape} class.
*/
public class getMinY implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
r.setFrame(1.0, 2.0, 3.0, 4.0);
harness.check(r.getMinY(), 2.0);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// it is probably overkill to test all these subclasses, but
// anyway...
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the intersects() method in the {@link RectangularShape} class.
* Only the most general checks are performed here, more specific tests should
* be done at the level of the subclass.
*/
public class intersects implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
boolean pass = false;
try
{
r.intersects(null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the isEmpty() method in the {@link RectangularShape} class.
* Only the most general checks are performed here, more specific tests should
* be done at the level of the subclass.
*/
public class isEmpty implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
r.setFrame(0.0, 0.0, 0.0, 0.0);
harness.check(r.isEmpty());
r.setFrame(-1.0, -2.0, -3.0, -4.0);
harness.check(r.isEmpty());
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the setFrameFromCenter() method in the {@link RectangularShape}
* class. Only the most general checks are performed here, more specific tests
* should be done at the level of the subclass.
*/
public class setFrameFromCenter implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
// setFrameFromCenter(double, double, double, double)
r.setFrameFromCenter(1.0, 2.0, 3.0, 4.0);
harness.check(r.getX(), -1.0);
harness.check(r.getY(), 0.0);
harness.check(r.getWidth(), 4.0);
harness.check(r.getHeight(), 4.0);
// setFrameFromCenter(Point2D, Point2D)
r.setFrameFromCenter(
new Point2D.Double(4.0, 3.0), new Point2D.Double(2.0, 1.0)
);
harness.check(r.getX(), 2.0);
harness.check(r.getY(), 1.0);
harness.check(r.getWidth(), 4.0);
harness.check(r.getHeight(), 4.0);
boolean pass = false;
try
{
r.setFrameFromCenter(null, new Point2D.Double());
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
pass = false;
try
{
r.setFrameFromCenter(new Point2D.Double(), null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the setFrameFromDiagonal() method in the {@link RectangularShape}
* class. Only the most general checks are performed here, more specific tests
* should be done at the level of the subclass.
*/
public class setFrameFromDiagonal implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
// setFrameFromDiagonal(double, double, double, double)
r.setFrameFromDiagonal(1.0, 2.0, 3.0, 4.0);
harness.check(r.getX(), 1.0);
harness.check(r.getY(), 2.0);
harness.check(r.getWidth(), 2.0);
harness.check(r.getHeight(), 2.0);
// setFrameFromDiagonal(Point2D, Point2D)
r.setFrameFromDiagonal(
new Point2D.Double(4.0, 3.0), new Point2D.Double(2.0, 1.0)
);
harness.check(r.getX(), 2.0);
harness.check(r.getY(), 1.0);
harness.check(r.getWidth(), 2.0);
harness.check(r.getHeight(), 2.0);
boolean pass = false;
try
{
r.setFrameFromDiagonal(null, new Point2D.Double());
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
pass = false;
try
{
r.setFrameFromDiagonal(new Point2D.Double(), null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}
//Tags: JDK1.2
//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.
//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING. If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA. */
package gnu.testlet.java.awt.geom.RectangularShape;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;
/**
* Some checks for the setFrame() method in the {@link RectangularShape} class.
* Only the most general checks are performed here, more specific tests should
* be done at the level of the subclass.
*/
public class setFrame implements Testlet
{
/**
* Run some tests for an instance of a subclass of {@link RectangularShape}.
*
* @param r the rectangular shape.
* @param harness the test harness.
*/
public static void testOneInstance(RectangularShape r, TestHarness harness)
{
// setFrame(double, double, double, double)
r.setFrame(1.0, 2.0, 3.0, 4.0);
harness.check(r.getX(), 1.0);
harness.check(r.getY(), 2.0);
harness.check(r.getWidth(), 3.0);
harness.check(r.getHeight(), 4.0);
// setFrame(Point2D, Dimension2D)
r.setFrame(new Point2D.Double(4.0, 3.0), new Dimension(2, 1));
harness.check(r.getX(), 4.0);
harness.check(r.getY(), 3.0);
harness.check(r.getWidth(), 2.0);
harness.check(r.getHeight(), 1.0);
boolean pass = false;
try
{
r.setFrame(null, new Dimension(2, 1));
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
pass = false;
try
{
r.setFrame(new Point2D.Double(4.0, 3.0), null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
// setFrame(Rectangle2D)
r.setFrame(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
harness.check(r.getX(), 1.0);
harness.check(r.getY(), 2.0);
harness.check(r.getWidth(), 3.0);
harness.check(r.getHeight(), 4.0);
pass = false;
try
{
r.setFrame(null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
harness.checkPoint("Arc2D.Float");
testOneInstance(new Arc2D.Float(), harness);
harness.checkPoint("Arc2D.Double");
testOneInstance(new Arc2D.Double(), harness);
harness.checkPoint("Ellipse2D.Float");
testOneInstance(new Ellipse2D.Float(), harness);
harness.checkPoint("Ellipse2D.Double");
testOneInstance(new Ellipse2D.Double(), harness);
harness.checkPoint("Rectangle2D.Float");
testOneInstance(new Rectangle2D.Float(), harness);
harness.checkPoint("Rectangle2D.Double");
testOneInstance(new Rectangle2D.Double(), harness);
harness.checkPoint("RoundRectangle2D.Float");
testOneInstance(new RoundRectangle2D.Float(), harness);
harness.checkPoint("RoundRectangle2D.Double");
testOneInstance(new RoundRectangle2D.Double(), harness);
harness.checkPoint("Rectangle");
testOneInstance(new Rectangle(), harness);
}
}