This is the mail archive of the mauve-patches@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Area.java


It's great to see that Sven has checked in Area.java.  To help identify
any remaining bugs in the code, I've attached some Mauve test cases. 
Using JamVM 1.1.4 and the latest CVS version of Classpath, I get the
following failures:

dgilbert@linux42:~/workspace/mauve> jamvm -cp .
gnu.testlet.SimpleTestHarness -file CurrentTests.txt -debug
FAIL: gnu.testlet.java.awt.geom.Area.constructors (number 4)
FAIL: gnu.testlet.java.awt.geom.Area.contains (number 2)
FAIL: gnu.testlet.java.awt.geom.Area.contains (number 5)
FAIL: gnu.testlet.java.awt.geom.Area.equals: uncaught exception at 
number 4
java.lang.NullPointerException
   at java.awt.geom.Area.equals (Area.java:703)
   at gnu.testlet.java.awt.geom.Area.equals.test (equals.java:54)
   at gnu.testlet.SimpleTestHarness.runtest (SimpleTestHarness.java:266)
   at gnu.testlet.SimpleTestHarness.main (SimpleTestHarness.java:394)
FAIL: gnu.testlet.java.awt.geom.Area.exclusiveOr (number 1)
FAIL: gnu.testlet.java.awt.geom.Area.exclusiveOr (number 2)
FAIL: gnu.testlet.java.awt.geom.Area.exclusiveOr (number 5)
FAIL: gnu.testlet.java.awt.geom.Area.exclusiveOr (number 6)
FAIL: gnu.testlet.java.awt.geom.Area.exclusiveOr (number 12)
FAIL: gnu.testlet.java.awt.geom.Area.exclusiveOr (number 13)
FAIL: gnu.testlet.java.awt.geom.Area.exclusiveOr (number 16)
FAIL: gnu.testlet.java.awt.geom.Area.exclusiveOr (number 17)
FAIL: gnu.testlet.java.awt.geom.Area.intersect (number 6)
FAIL: gnu.testlet.java.awt.geom.Area.intersect (number 12)
FAIL: gnu.testlet.java.awt.geom.Area.intersects (number 10)
FAIL: gnu.testlet.java.awt.geom.Area.isRectangular (number 1)
FAIL: gnu.testlet.java.awt.geom.Area.isRectangular (number 2)
FAIL: gnu.testlet.java.awt.geom.Area.subtract (number 1)
FAIL: gnu.testlet.java.awt.geom.Area.subtract (number 2)
FAIL: gnu.testlet.java.awt.geom.Area.subtract (number 5)
FAIL: gnu.testlet.java.awt.geom.Area.subtract (number 6)
FAIL: gnu.testlet.java.awt.geom.Area.subtract (number 8)
FAIL: gnu.testlet.java.awt.geom.Area.subtract (number 11)
23 of 131 tests failed

With Sun's JDK 1.4 (on SuSE Linux 9.1) I get no failures:

dgilbert@linux42:~/workspace/mauve> java14 -cp .
gnu.testlet.SimpleTestHarness -file CurrentTests.txt -debug
0 of 131 tests failed

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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
* Tests the add() method for the {@link Area} class.
*/
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)      
  {
    Area area = new Area();
    area.add(new Area(new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0)));
    harness.check(area.isRectangular());
  
    boolean pass = false;
    try
    {
      area.add(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.geom.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the clone() method for the {@link Area} class.
 */
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)      
  {
    // clone an empty area
    Area area1 = new Area();
    Area area2 = (Area) area1.clone();;
    harness.check(area1.equals(area2));
    harness.check(area1 != area2);
  
    // try a simple case
    area1 = new Area(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    area2 = (Area) area1.clone();
    harness.check(area1.equals(area2));
    harness.check(area1 != area2);
  }

}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the constructors for the {@link Area} class.
 */
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)      
  {
    // constructor 1
    Area area = new Area();
    harness.check(area.isEmpty());
    harness.check(area.isSingular());
    
    // an empty area is treated as polygonal and rectangular
    harness.check(area.isPolygonal());
    harness.check(area.isRectangular());
    
    // constructor 2
    area = new Area(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    harness.check(!area.isEmpty());
    harness.check(area.isPolygonal());
    harness.check(area.isRectangular());
    harness.check(area.isSingular());
    
    boolean pass = false;
    try
    {
      area = new Area(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.geom.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

/**
 * Tests the contains() method for the {@link Area} class.
 */
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)      
  {
    // contains(double, double)
    Area area = new Area();
    harness.check(!area.contains(0.0, 0.0));
    
    area.add(new Area(new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0)));
    harness.check(area.contains(1.0, 1.0));
    harness.check(!area.contains(1.0, 2.0));
    harness.check(!area.contains(2.0, 1.0));
    harness.check(!area.contains(2.0, 2.0));

    // contains(Point2D)
    boolean pass = false;
    try
    {
      area.contains((Point2D) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
    
    // contains(Rectangle2D)
    pass = false;
    try
    {
      area.contains((Rectangle2D) 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.geom.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the createTransformedArea() method for the {@link Area} class.
 */
public class createTransformedArea implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    // test an empty area
    Area area1 = new Area();
    Area area2 = area1.createTransformedArea(AffineTransform.getScaleInstance(2.0, 2.0));
    harness.check(area1.isEmpty());
    harness.check(area2.isEmpty());
    harness.check(area1 != area2);

    // test a simple area
    area1 = new Area(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    AffineTransform at = AffineTransform.getScaleInstance(2.0, 2.0);
    area2 = area1.createTransformedArea(at);
    harness.check(area1 != area2);
    Rectangle2D b1 = area1.getBounds2D();
    Rectangle2D b2 = area2.getBounds2D();
    harness.check(b1.getX() == 1.0);
    harness.check(b1.getY() == 2.0);
    harness.check(b1.getWidth() == 3.0);
    harness.check(b1.getHeight() == 4.0);
    harness.check(b2.getX() == 2.0);
    harness.check(b2.getY() == 4.0);
    harness.check(b2.getWidth() == 6.0);
    harness.check(b2.getHeight() == 8.0);
   
    // null transform should throw exception
    boolean pass = false;
    try {
      area2 = area1.createTransformedArea(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.geom.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the equals() method for the {@link Area} class.
 */
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)      
  {
    // be aware that the equals(Object) method is NOT overridden (see
    // bug parade id 4391558)...
    Area area1 = new Area();
    Area area2 = new Area();
    harness.check(area1.equals(area2));
    harness.check(!area1.equals((Object) area2));
    
    // try a simple case
    area1 = new Area(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    area2 = new Area(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    harness.check(area1.equals(area2));

    // equals(null) should return false
    Area area3 = new Area();
    harness.check(!area3.equals(null));
  }

}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the exclusiveOr() method for the {@link Area} class.
 */
public class exclusiveOr implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Area area = new Area();
    area.add(new Area(new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0)));
    area.exclusiveOr(new Area(new Rectangle2D.Double(0.0, 0.0, 2.0, 2.0)));
    harness.check(area.contains(-1.0, -1.0));  // check 1
    harness.check(area.contains(-1.0, 0.0));   // check 2
    harness.check(!area.contains(-1.0, 1.0));  // check 3
    harness.check(!area.contains(-1.0, 2.0));  // check 4
    harness.check(area.contains(0.0, -1.0));   // check 5
    harness.check(!area.contains(0.0, 0.0));   // check 6
    harness.check(!area.contains(0.5, 0.5));   // check 7
    harness.check(area.contains(0.0, 1.0));    // check 8
    harness.check(!area.contains(0.0, 2.0));   // check 9
    harness.check(!area.contains(1.0, -1.0));  // check 10
    harness.check(area.contains(1.0, 0.0));    // check 11
    harness.check(area.contains(1.0, 1.0));    // check 12
    harness.check(!area.contains(1.0, 2.0));   // check 13
    harness.check(!area.contains(2.0, -1.0));  // check 14
    harness.check(!area.contains(2.0, 0.0));   // check 15
    harness.check(!area.contains(2.0, 1.0));   // check 16
    harness.check(!area.contains(2.0, 2.0));   // check 17

    boolean pass = false;
    try
    {
      area.exclusiveOr(null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);                       // check 18
  }

}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the getBounds2D() method for the {@link Area} class.
 */
public class getBounds2D implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    // test an empty area
    Area area1 = new Area();
    Rectangle2D r = area1.getBounds2D();
    harness.check(r.isEmpty());

    // try a simple case
    area1 = new Area(new Rectangle2D.Double(0.5, 0.5, 1.0, 1.0));
    r = area1.getBounds2D();
    harness.check(r.equals(new Rectangle2D.Double(0.5, 0.5, 1.0, 1.0)));
  }
 
}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.Rectangle;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the getBounds() method for the {@link Area} class.
 */
public class getBounds implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    // test an empty area
    Area area1 = new Area();
    Rectangle r = area1.getBounds();
    harness.check(r.isEmpty());

    // try a simple case
    area1 = new Area(new Rectangle2D.Double(0.5, 0.5, 1.0, 1.0));
    r = area1.getBounds();
    harness.check(r.equals(new Rectangle(0, 0, 2, 2)));
  }

}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the intersect() method for the {@link Area} class.
 */
public class intersect implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Area area = new Area();
    area.add(new Area(new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0)));
    area.intersect(new Area(new Rectangle2D.Double(0.0, 0.0, 2.0, 2.0)));
    harness.check(!area.contains(-1.0, -1.0));  // check 1
    harness.check(!area.contains(-1.0, 0.0));   // check 2
    harness.check(!area.contains(-1.0, 1.0));   // check 3
    harness.check(!area.contains(-1.0, 2.0));   // check 4
    harness.check(!area.contains(0.0, -1.0));   // check 5
    harness.check(area.contains(0.0, 0.0));     // check 6
    harness.check(area.contains(0.5, 0.5));     // check 7
    harness.check(!area.contains(0.0, 1.0));    // check 8
    harness.check(!area.contains(0.0, 2.0));    // check 9
    harness.check(!area.contains(1.0, -1.0));   // check 10
    harness.check(!area.contains(1.0, 0.0));    // check 11
    harness.check(!area.contains(1.0, 1.0));    // check 12
    harness.check(!area.contains(1.0, 2.0));    // check 13
    harness.check(!area.contains(2.0, -1.0));   // check 14
    harness.check(!area.contains(2.0, 0.0));    // check 15
    harness.check(!area.contains(2.0, 1.0));    // check 16
    harness.check(!area.contains(2.0, 2.0));    // check 17
  
    boolean pass = false;
    try
    {
      area.intersect(null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);                        // check 18
  }

}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the intersects() method for the {@link Area} class.
 */
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)      
  {
    // intersects(double, double, double, double)
    Area area = new Area();
    harness.check(!area.intersects(0.0, 0.0, 0.0, 0.0));  // 1
  
    area.add(new Area(new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0)));
    harness.check(!area.intersects(0.0, 0.0, 1.0, 1.0));  // 2
    harness.check(!area.intersects(1.0, 0.0, 1.0, 1.0));  // 3
    harness.check(!area.intersects(2.0, 0.0, 1.0, 1.0));  // 4
    harness.check(!area.intersects(0.0, 1.0, 1.0, 1.0));  // 5
    harness.check(area.intersects(1.0, 1.0, 1.0, 1.0));   // 6
    harness.check(!area.intersects(2.0, 1.0, 1.0, 1.0));  // 7
    harness.check(!area.intersects(0.0, 2.0, 1.0, 1.0));  // 8
    harness.check(!area.intersects(1.0, 2.0, 1.0, 1.0));  // 9
    harness.check(!area.intersects(2.0, 2.0, 1.0, 1.0));  // 10

    // intersects(Rectangle2D)
    area = new Area();
    boolean pass = false;
    try
    {
      area.intersects((Rectangle2D) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);                                  // 11
  }
}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;

/**
 * Some tests for the isEmpty() method in the {@link Area} class.
 */
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)      
  {
    Area area = new Area();
    harness.check(area.isEmpty());
    
    area = new Area(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
    harness.check(area.isEmpty());

    area = new Area(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    harness.check(!area.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.geom.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;

/**
 * Some tests for the isPolygonal() method in the {@link Area} class.
 */
public class isPolygonal implements Testlet {

  /**
   * Runs the test using the specified harness. 
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Area area = new Area();
    harness.check(area.isPolygonal());
    area.add(new Area(new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0)));
    harness.check(area.isPolygonal());
    area.add(new Area(new Rectangle2D.Double(10.0, 10.0, 1.0, 1.0)));
    harness.check(area.isPolygonal());
    
    area = new Area(new Ellipse2D.Double());
    harness.check(area.isPolygonal());

    area = new Area(new Ellipse2D.Double(1.0, 2.0, 3.0, 4.0));
    harness.check(!area.isPolygonal());
  }

}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;

/**
 * Some tests for the isRectangular() method in the {@link Area} class.
 */
public class isRectangular implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {

    // an empty area is treated as being rectangular
    Area area = new Area();
    harness.check(area.isRectangular());
    area = new Area(new Ellipse2D.Double());
    harness.check(area.isRectangular());

    area.add(new Area(new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0)));
    harness.check(area.isRectangular());
    area.add(new Area(new Rectangle2D.Double(10.0, 10.0, 1.0, 1.0)));
    harness.check(!area.isRectangular());
    
    area = new Area(new Ellipse2D.Double(1.0, 2.0, 3.0, 4.0));
    harness.check(!area.isRectangular());
  }

}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Some tests for the isSingular() method in the {@link Area} class.
 */
public class isSingular implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Area area = new Area();
    harness.check(area.isSingular());
    area.add(new Area(new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0)));
    harness.check(area.isSingular());
    area.add(new Area(new Rectangle2D.Double(10.0, 10.0, 1.0, 1.0)));
    harness.check(!area.isSingular());
  }

}
//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.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Some tests for the reset() method in the {@link Area} class.
 */
public class reset implements Testlet {

  /**
   * Runs the test using the specified harness. 
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Area area = new Area();
    area.add(new Area(new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0)));
    harness.check(!area.isEmpty());
    area.reset();
    harness.check(area.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.geom.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the subtract() method for the {@link Area} class.
 */
public class subtract implements Testlet {
  
  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Area area = new Area();
    area.add(new Area(new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0)));
    area.subtract(new Area(new Rectangle2D.Double(0.0, 0.0, 2.0, 2.0)));
    harness.check(area.contains(-1.0, -1.0));  // check 1
    harness.check(area.contains(-1.0, 0.0));   // check 2
    harness.check(!area.contains(-1.0, 1.0));  // check 3
    harness.check(!area.contains(-1.0, 2.0));  // check 4
    harness.check(area.contains(0.0, -1.0));   // check 5
    harness.check(!area.contains(0.0, 0.0));   // check 6
    harness.check(!area.contains(0.5, 0.5));   // check 7
    harness.check(!area.contains(0.0, 1.0));    // check 8
    harness.check(!area.contains(0.0, 2.0));   // check 9
    harness.check(!area.contains(1.0, -1.0));  // check 10
    harness.check(!area.contains(1.0, 0.0));    // check 11
    harness.check(!area.contains(1.0, 1.0));    // check 12
    harness.check(!area.contains(1.0, 2.0));   // check 13
    harness.check(!area.contains(2.0, -1.0));  // check 14
    harness.check(!area.contains(2.0, 0.0));   // check 15
    harness.check(!area.contains(2.0, 1.0));   // check 16
    harness.check(!area.contains(2.0, 2.0));   // check 17
        
    boolean pass = false;
    try
    {
      area.subtract(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.geom.Area;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;

/**
 * Tests the transform() method for the {@link Area} class.
 */
public class transform implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Area area = new Area(new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0));
    area.transform(AffineTransform.getScaleInstance(2.0, 2.0));
    Rectangle2D bounds = area.getBounds2D();
    harness.check(bounds.getX(), 0.0);
    harness.check(bounds.getY(), 0.0);
    harness.check(bounds.getWidth(), 2.0);
    harness.check(bounds.getHeight(), 2.0);
    
    boolean pass = false;
    try
    {
      area.transform(null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
  }

}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]