This is the mail archive of the
mauve-patches@sources.redhat.com
mailing list for the Mauve project.
Tests for java.awt.Rectangle
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Wed, 11 Aug 2004 10:25:46 +0100
- Subject: Tests for java.awt.Rectangle
I've attached some test cases for the java.awt.Rectangle class. Results
on my machine (SuSE Linux 9.1) using JamVM 1.1.4 and a recent CVS
version of Classpath show just one failure (a fairly minor one):
dgilbert@linux42:~/workspace/mauve> jamvm gnu.testlet.SimpleTestHarness
-file CurrentTests.txt
FAIL: gnu.testlet.java.awt.Rectangle.intersects (number 7)
1 of 125 tests failed
All checks pass with Sun's JDK 1.3 and 1.4:
dgilbert@linux42:~/workspace/mauve> java13 gnu.testlet.SimpleTestHarness
-file CurrentTests.txt
0 of 125 tests failed
dgilbert@linux42:~/workspace/mauve> java14 gnu.testlet.SimpleTestHarness
-file CurrentTests.txt
0 of 125 tests failed
Regards,
Dave Gilbert
www.jfree.org
//Tags: JDK1.0
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Point;
import java.awt.Rectangle;
/**
* Checks that the add() method works correctly.
*/
public class add implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r = new Rectangle();
r.add(5, 7);
harness.check(r.x == 0);
harness.check(r.y == 0);
harness.check(r.width == 5);
harness.check(r.height == 7);
boolean pass = false;
try {
r.add((Point) null);
}
catch (NullPointerException e) {
pass = true;
}
harness.check(pass);
pass = false;
try {
r.add((Rectangle) null);
}
catch (NullPointerException e) {
pass = true;
}
harness.check(pass);
}
}
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the clone() method works correctly.
*/
public class clone implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r1 = new Rectangle(1, 2, 3, 4);
Rectangle r2 = null;
r2 = (Rectangle) r1.clone();
harness.check(r1 != r2);
harness.check(r1.getClass().equals(r2.getClass()));
harness.check(r1.x == r2.x);
harness.check(r1.y == r2.y);
harness.check(r1.width == r2.width);
harness.check(r1.height == r2.height);
}
}
//Tags: JDK1.0
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Point;
import java.awt.Rectangle;
/**
* Checks that the contains() method works correctly.
*/
public class contains implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r = new Rectangle();
harness.check(!r.contains(0, 0));
harness.check(!r.contains(1, 1));
// a rectangle with negative width and height doesn't contain anything
r = new Rectangle(0, 0, -10, -10);
harness.check(!r.contains(-5, -5));
harness.check(!r.contains(0, 0));
// a rectangle contains itself but not every point
r = new Rectangle(0, 0, 10, 10);
harness.check(r.contains(0, 0, 10, 10));
harness.check(!r.contains(10, 10));
// check null arguments
boolean pass = false;
try
{
r.contains((Point) null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
pass = false;
try
{
r.contains((Rectangle) null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
}
//Tags: JDK1.0
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the equals() method works correctly.
*/
public class equals implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r0 = new Rectangle(0, 0, 0, 0);
Rectangle r1 = new Rectangle(0, 0, 0, 0);
harness.check(r0.equals(r1));
harness.check(r1.equals(r0));
r0.x = 1;
harness.check(!r0.equals(r1));
r1.x = 1;
harness.check(r0.equals(r1));
r0.y = 2;
harness.check(!r0.equals(r1));
r1.y = 2;
harness.check(r0.equals(r1));
r0.width = 3;
harness.check(!r0.equals(r1));
r1.width = 3;
harness.check(r0.equals(r1));
r0.height = 4;
harness.check(!r0.equals(r1));
r1.height = 4;
harness.check(r0.equals(r1));
}
}
//Tags: JDK1.0
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the grow() method works correctly.
*/
public class grow implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r = new Rectangle(0, 0, 0, 0);
r.grow(5, 7);
harness.check(r.x == -5);
harness.check(r.y == -7);
harness.check(r.width == 10);
harness.check(r.height == 14);
}
}
//Tags: JDK1.1
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the intersection() method works correctly.
*/
public class intersection implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r0 = new Rectangle(0, 0, 0, 0);
Rectangle r1 = new Rectangle(1, 2, 3, 4);
Rectangle r2 = new Rectangle(1, 2, 4, 3);
Rectangle r3 = new Rectangle(10, 10, 0, 0);
Rectangle r = r0.intersection(r1);
harness.check(r.isEmpty());
r = r1.intersection(r2);
harness.check(r.equals(new Rectangle(1, 2, 3, 3)));
r = r2.intersection(r3);
harness.check(r.isEmpty());
// check null argument
boolean pass = false;
try {
r0.intersection(null);
}
catch (NullPointerException e) {
pass = true;
}
harness.check(pass);
}
}
//Tags: JDK1.1
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the intersects() method works correctly.
*/
public class intersects implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r0 = new Rectangle(0, 0, 0, 0);
Rectangle r1 = new Rectangle(0, 0, 1, 1);
Rectangle r2 = new Rectangle(1, 1, 1, 1);
Rectangle r3 = new Rectangle(-1, -1, 1, 1);
Rectangle r4 = new Rectangle(-1, -1, 2, 2);
Rectangle r5 = new Rectangle(-1, -1, 3, 3);
harness.check(!r0.intersects(r1));
harness.check(!r0.intersects(r2));
harness.check(!r1.intersects(r2));
harness.check(!r2.intersects(r3));
harness.check(!r2.intersects(r4));
harness.check(r2.intersects(r5));
// check null argument
boolean pass = false;
try
{
r0.intersects(null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
}
//Tags: JDK1.0
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the isEmpty() method works correctly.
*/
public class isEmpty implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r = new Rectangle();
harness.check(r.isEmpty());
r = new Rectangle(0, 0, 100, 0);
harness.check(r.isEmpty());
r = new Rectangle(0, 0, 0, 100);
harness.check(r.isEmpty());
r = new Rectangle(0, 0, -10, -10);
harness.check(r.isEmpty());
r = new Rectangle(0, 0, 1, 1);
harness.check(!r.isEmpty());
}
}
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
/**
* Checks that the outcode() method works correctly.
*/
public class outcode implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r = new Rectangle(0, 0, 10, 10);
harness.check(r.outcode(5, 5) == 0);
harness.check(r.outcode(0, 0) == 0);
harness.check(r.outcode(0, 10) == 0);
harness.check(r.outcode(10, 0) == 0);
harness.check(r.outcode(10, 10) == 0);
harness.check(r.outcode(-5, 5) == Rectangle2D.OUT_LEFT);
harness.check(r.outcode(15, 5) == Rectangle2D.OUT_RIGHT);
harness.check(r.outcode(5, -5) == Rectangle2D.OUT_TOP);
harness.check(r.outcode(5, 15) == Rectangle2D.OUT_BOTTOM);
harness.check(r.outcode(-5, -5) == (Rectangle2D.OUT_LEFT
| Rectangle2D.OUT_TOP));
harness.check(r.outcode(15, -5) == (Rectangle2D.OUT_RIGHT
| Rectangle2D.OUT_TOP));
harness.check(r.outcode(15, 15) == (Rectangle2D.OUT_RIGHT
| Rectangle2D.OUT_BOTTOM));
harness.check(r.outcode(-5, 15) == (Rectangle2D.OUT_LEFT
| Rectangle2D.OUT_BOTTOM));
// check an empty rectangle - all points should be outside
r = new Rectangle(0, 0, 0, 0);
int outside = Rectangle2D.OUT_LEFT | Rectangle2D.OUT_RIGHT
| Rectangle2D.OUT_TOP | Rectangle2D.OUT_BOTTOM;
harness.check(r.outcode(-1, -1) == outside);
harness.check(r.outcode(-1, 0) == outside);
harness.check(r.outcode(-1, 1) == outside);
harness.check(r.outcode(0, -1) == outside);
harness.check(r.outcode(0, 0) == outside);
harness.check(r.outcode(0, 1) == outside);
harness.check(r.outcode(1, -1) == outside);
harness.check(r.outcode(1, 0) == outside);
harness.check(r.outcode(1, 1) == outside);
r = new Rectangle(0, 0, -10, -10);
harness.check(r.outcode(-1, -1) == outside);
harness.check(r.outcode(-1, 0) == outside);
harness.check(r.outcode(-1, 1) == outside);
harness.check(r.outcode(0, -1) == outside);
harness.check(r.outcode(0, 0) == outside);
harness.check(r.outcode(0, 1) == outside);
harness.check(r.outcode(1, -1) == outside);
harness.check(r.outcode(1, 0) == outside);
harness.check(r.outcode(1, 1) == outside);
}
}
//Tags: JDK1.1
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the setBounds() method works correctly.
*/
public class setBounds implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r1 = new Rectangle(1, 2, 3, 4);
r1.setBounds(5, 6, 7, 8);
harness.check(r1.x == 5);
harness.check(r1.y == 6);
harness.check(r1.width == 7);
harness.check(r1.height == 8);
r1 = new Rectangle();
r1.setBounds(new Rectangle(5, 6, 7, 8));
harness.check(r1.x == 5);
harness.check(r1.y == 6);
harness.check(r1.width == 7);
harness.check(r1.height == 8);
// check null argument
boolean pass = false;
try
{
r1.setBounds(null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
}
//Tags: JDK1.1
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Point;
import java.awt.Rectangle;
/**
* Checks that the setLocation() method works correctly.
*/
public class setLocation implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r1 = new Rectangle(1, 2, 3, 4);
r1.setLocation(5, 6);
harness.check(r1.x == 5);
harness.check(r1.y == 6);
harness.check(r1.width == 3);
harness.check(r1.height == 4);
r1 = new Rectangle(1, 2, 3, 4);
r1.setLocation(new Point(5, 6));
harness.check(r1.x == 5);
harness.check(r1.y == 6);
harness.check(r1.width == 3);
harness.check(r1.height == 4);
// check null argument
boolean pass = false;
try
{
r1.setLocation(null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
}
//Tags: JDK1.0
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the setRect() method works correctly.
*/
public class setRect implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r1 = new Rectangle(1, 2, 3, 4);
r1.setRect(5, 6, 7, 8);
harness.check(r1.x == 5);
harness.check(r1.y == 6);
harness.check(r1.width == 7);
harness.check(r1.height == 8);
}
}
//Tags: JDK1.0
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Dimension;
import java.awt.Rectangle;
/**
* Checks that the setSize() method works correctly.
*/
public class setSize implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r1 = new Rectangle(1, 2, 3, 4);
r1.setSize(5, 6);
harness.check(r1.x == 1);
harness.check(r1.y == 2);
harness.check(r1.width == 5);
harness.check(r1.height == 6);
r1 = new Rectangle(1, 2, 3, 4);
r1.setSize(new Dimension(5, 6));
harness.check(r1.x == 1);
harness.check(r1.y == 2);
harness.check(r1.width == 5);
harness.check(r1.height == 6);
// check null argument
boolean pass = false;
try
{
r1.setSize(null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
}
//Tags: JDK1.0
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the translate() method works correctly.
*/
public class translate implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r1 = new Rectangle(1, 2, 3, 4);
r1.translate(5, 6);
harness.check(r1.x == 6);
harness.check(r1.y == 8);
harness.check(r1.width == 3);
harness.check(r1.height == 4);
}
}
//Tags: JDK1.0
//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.Rectangle;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Rectangle;
/**
* Checks that the union() method works correctly.
*/
public class union implements Testlet {
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Rectangle r1 = new Rectangle(1, 2, 3, 4);
Rectangle r2 = new Rectangle(5, 6, 7, 8);
Rectangle r3 = r1.union(r2);
harness.check(r3.x == 1);
harness.check(r3.y == 2);
harness.check(r3.width == 11);
harness.check(r3.height == 12);
// check union with empty rectangle
r1 = new Rectangle();
r2 = new Rectangle(1, 2, 3, 4);
r3 = r1.union(r2);
harness.check(r3.x == 0);
harness.check(r3.y == 0);
harness.check(r3.width == 4);
harness.check(r3.height == 6);
// check null argument
boolean pass = false;
try
{
r3 = r1.union(null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
}