This is the mail archive of the
mauve-patches@sources.redhat.com
mailing list for the Mauve project.
Tests for java.awt.Dimension
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches at sources dot redhat dot com
- Cc: mark at klomp dot org
- Date: Mon, 09 Aug 2004 09:54:07 +0100
- Subject: Tests for java.awt.Dimension
Please find attached some simple test cases for the java.awt.Dimension
class. Results on my machine (SuSE Linux 9.1) using JamVM 1.1.4 and a
very recent CVS version of Classpath:
dgilbert@linux42:~/workspace/mauve> jamvm gnu.testlet.SimpleTestHarness
-file CurrentTests.txt
FAIL: gnu.testlet.java.awt.Dimension.setSize (number 5)
FAIL: gnu.testlet.java.awt.Dimension.setSize (number 6)
2 of 31 tests failed
dgilbert@linux42:~/workspace/mauve> java13 gnu.testlet.SimpleTestHarness
-file CurrentTests.txt
FAIL: gnu.testlet.java.awt.Dimension.setSize (number 3)
FAIL: gnu.testlet.java.awt.Dimension.setSize (number 4)
FAIL: gnu.testlet.java.awt.Dimension.setSize (number 5)
FAIL: gnu.testlet.java.awt.Dimension.setSize (number 6)
4 of 31 tests failed
dgilbert@linux42:~/workspace/mauve> java14 gnu.testlet.SimpleTestHarness
-file CurrentTests.txt
0 of 31 tests failed
The failure with Classpath I have reported here:
http://savannah.gnu.org/bugs/?func=detailitem&item_id=9895
...with discussion on the mailing list suggesting that this is a bug in
JamVM's conversion of 'double' to 'int'.
The failure with JDK 1.3.1_11 is a long-standing bug that has been fixed
in JDK 1.4 (see bug parade reports 4245442 and 4976448) but not JDK 1.3.
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.Dimension;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Dimension;
/**
* Checks that the clone() method in the {@link Dimension} class 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)
{
Dimension d1 = new Dimension(44, 55);
Dimension d2 = null;
d2 = (java.awt.Dimension) d1.clone();
harness.check(d1 != d2);
harness.check(d1.getClass().equals(d2.getClass()));
harness.check(d1.width == d2.width);
harness.check(d1.height == d2.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.Dimension;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Dimension;
/**
* Checks that constructors in the {@link Dimension} class work
* correctly.
*/
public class constructors implements Testlet
{
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// default constructor
Dimension d = new Dimension();
harness.check(d.getWidth() == 0.0);
harness.check(d.getHeight() == 0.0);
// (int, int) constructor
d = new Dimension(5, 10);
harness.check(d.getWidth() == 5);
harness.check(d.getHeight() == 10);
// (Dimension) constructor
Dimension d1 = new Dimension(100, 200);
Dimension d2 = new Dimension(d1);
harness.check(d2.getWidth() == 100);
harness.check(d2.getHeight() == 200);
// check that d2 is independent of d1
d1.width = 1;
d1.height = 2;
harness.check(d2.getWidth() == 100);
harness.check(d2.getHeight() == 200);
// check for null argument
boolean pass = false;
try
{
Dimension d3 = new Dimension(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.Dimension;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Dimension;
/**
* Checks that the equals() method in the {@link Dimension} class 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)
{
Dimension d1 = new Dimension();
Dimension d2 = new Dimension();
harness.check(d1.equals(d2));
harness.check(d2.equals(d1));
harness.check(!d1.equals(null));
d1.width = 5;
harness.check(!d1.equals(d2));
d2.width = 5;
harness.check(d1.equals(d2));
d1.height = 10;
harness.check(!d1.equals(d2));
d2.height = 10;
harness.check(d1.equals(d2));
}
}
//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.Dimension;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Dimension;
/**
* Checks that the getSize() method in the {@link Dimension} class works
* correctly.
*/
public class getSize implements Testlet
{
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
Dimension d1 = new Dimension(11, 22);
Dimension d2 = d1.getSize();
harness.check(d2.width == 11);
harness.check(d2.height == 22);
d2.width = 1;
d2.height = 2;
harness.check(d1.width == 11);
harness.check(d1.height == 22);
}
}
//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.Dimension;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Dimension;
/**
* Checks that the setSize() method in the {@link Dimension} class works
* correctly. See Sun's bug parade reports 4245442 and 4976448. This
* is still a problem in JDK 1.3.1_11.
*/
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)
{
Dimension d = new Dimension();
d.setSize(1, 2);
harness.check(d.getWidth() == 1);
harness.check(d.getHeight() == 2);
d.setSize(5.0, 10.0);
harness.check(d.getWidth() == 5.0);
harness.check(d.getHeight() == 10.0);
double w = Integer.MAX_VALUE + 100000.0;
double h = Integer.MAX_VALUE + 200000.0;
d.setSize(w, h);
harness.check(d.getWidth() == Integer.MAX_VALUE);
harness.check(d.getHeight() == Integer.MAX_VALUE);
// check for null argument
boolean pass = false;
try
{
d.setSize(null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
}
}