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]

Tests for Arc2D class


Please find attached a set of tests for the Arc2D class.  All checks
(181) pass with Sun's JDK1.3.1 and JDK 1.4.2 (on SuSE Linux 9.1).  In
Classpath, the Arc2D implementation is not complete, so there are some
failures.  I believe Sven de Marothy is working on this class, so
hopefully these tests will be helpful for that effort.

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

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

import java.awt.geom.Arc2D;

/**
 * Checks that Arc2D.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) 
  {
    Arc2D arc1 = new Arc2D.Double(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, Arc2D.PIE);
    Arc2D arc2 = null;
    arc2 = (Arc2D) arc1.clone();
    harness.check(arc1.getX() == arc2.getX());
    harness.check(arc1.getY() == arc2.getY());
    harness.check(arc1.getWidth() == arc2.getWidth());
    harness.check(arc1.getHeight() == arc2.getHeight());
    harness.check(arc1.getClass() == arc2.getClass());
    harness.check(arc1.getAngleStart(), arc2.getAngleStart());
    harness.check(arc1.getAngleExtent(), arc2.getAngleExtent());
    harness.check(arc1.getArcType() == arc2.getArcType());
    harness.check(arc1 != arc2);
  }

}
//Tags: JDK1.4

//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.Arc2D;

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

import java.awt.geom.Arc2D;

/**
 * Verifies constant values for the {@link Arc2D} class.
 */
public class constants implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    harness.check(Arc2D.CHORD == 1);
    harness.check(Arc2D.OPEN == 0);
    harness.check(Arc2D.PIE == 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.Arc2D;

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

import java.awt.geom.Arc2D;
import java.awt.geom.Rectangle2D;

/**
 * Tests the constructors for the {@link Arc2D} 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
    Arc2D arc = new Arc2D.Double();
    harness.check(arc.getArcType() == Arc2D.OPEN);
    harness.check(arc.getX(), 0.0);
    harness.check(arc.getY(), 0.0);
    harness.check(arc.getWidth(), 0.0);
    harness.check(arc.getHeight(), 0.0);
    harness.check(arc.getAngleStart(), 0.0);
    harness.check(arc.getAngleExtent(), 0.0);
    
    // constructor 2
    arc = new Arc2D.Double(Arc2D.PIE);
    harness.check(arc.getArcType() == Arc2D.PIE);
    harness.check(arc.getX(), 0.0);
    harness.check(arc.getY(), 0.0);
    harness.check(arc.getWidth(), 0.0);
    harness.check(arc.getHeight(), 0.0);
    harness.check(arc.getAngleStart(), 0.0);
    harness.check(arc.getAngleExtent(), 0.0);
    
    // constructor 3
    arc = new Arc2D.Double(1.0, 2.0, 3.0, 4.0, 45, 90.0, Arc2D.CHORD);
    harness.check(arc.getArcType() == Arc2D.CHORD);
    harness.check(arc.getX(), 1.0);
    harness.check(arc.getY(), 2.0);
    harness.check(arc.getWidth(), 3.0);
    harness.check(arc.getHeight(), 4.0);
    harness.check(arc.getAngleStart(), 45.0);
    harness.check(arc.getAngleExtent(), 90.0);
    
    boolean pass = false;
    try 
    {
      arc = new Arc2D.Double(1.0, 2.0, 3.0, 4.0, 45, 90.0, 99); 
    }
    catch (IllegalArgumentException e) 
    {
      pass = true;
    }
    harness.check(pass);
    
    // constructor 4
    arc = new Arc2D.Double(new Rectangle2D.Double(10.0, 11.0, 12.0, 13.0), 
            110.0, 35.0, Arc2D.OPEN);
    harness.check(arc.getArcType() == Arc2D.OPEN);
    harness.check(arc.getX(), 10.0);
    harness.check(arc.getY(), 11.0);
    harness.check(arc.getWidth(), 12.0);
    harness.check(arc.getHeight(), 13.0);
    harness.check(arc.getAngleStart(), 110.0);
    harness.check(arc.getAngleExtent(), 35.0);

    pass = false;
    try 
    {
      arc = new Arc2D.Double(null, 110.0, 35.0, Arc2D.OPEN);        
    }
    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.Arc2D;

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

import java.awt.geom.Arc2D;
import java.awt.geom.Rectangle2D;

/**
 * Tests the containsAngle() method of the {@link Arc2D} class.
 */
public class containsAngle implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Arc2D arc = new Arc2D.Double();
    harness.check(!arc.containsAngle(0.0));   // check 1

    arc = new Arc2D.Double(
      new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0), 90.0, 90.0, Arc2D.PIE
    );
    harness.check(!arc.containsAngle(0.0));   // check 2
    harness.check(!arc.containsAngle(45.0));  // check 3 
    harness.check(arc.containsAngle(90.0));   // check 4
    harness.check(arc.containsAngle(135.0));  // check 5
    harness.check(!arc.containsAngle(180.0)); // check 6
    harness.check(!arc.containsAngle(225.0)); // check 7
  }

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

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

import java.awt.geom.Arc2D;
import java.awt.geom.Rectangle2D;

/**
 * Tests the isEmpty() method of the {@link Arc2D} 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)
    Arc2D arc = new Arc2D.Double();
    harness.check(!arc.contains(0.0, 0.0));  // check 1
    
    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.CHORD);
    harness.check(!arc.contains(0.0, 0.0));  // check 2
    harness.check(!arc.contains(1.0, 0.0));  // check 3
    harness.check(!arc.contains(0.0, 1.0));  // check 4
    harness.check(!arc.contains(0.5, 0.5));  // check 5
    harness.check(!arc.contains(0.5, -0.5)); // check 6

    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.PIE);
    harness.check(arc.contains(0.0, 0.0));   // check 7
    harness.check(!arc.contains(1.0, 0.0));  // check 8
    harness.check(!arc.contains(0.0, 1.0));  // check 9
    harness.check(!arc.contains(0.5, 0.5));  // check 10
    harness.check(arc.contains(0.5, -0.5));  // check 11
    
    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.OPEN);
    harness.check(!arc.contains(0.0, 0.0));  // check 12
    harness.check(!arc.contains(1.0, 0.0));  // check 13
    harness.check(!arc.contains(0.0, 1.0));  // check 14
    harness.check(!arc.contains(0.5, 0.5));  // check 15
    harness.check(!arc.contains(0.5, -0.5)); // check 16
    
    // contains(double, double, double, double)
    arc = new Arc2D.Double();
    harness.check(!arc.contains(0.0, 0.0, 0.0, 0.0));  // check 17
    
    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.CHORD);
    harness.check(!arc.contains(0.45, -0.55, 0.1, 0.1));  // check 18
   
    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.PIE);
    harness.check(arc.contains(0.45, -0.55, 0.1, 0.1));   // check 19
   
    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.OPEN);
    harness.check(!arc.contains(0.45, -0.55, 0.1, 0.1));  // check 20
    
    // contains(Rectangle2D)
    arc = new Arc2D.Double();
    harness.check(                                       // check 21
      !arc.contains(new Rectangle2D.Double(0.0, 0.0, 0.0, 0.0))
    );
    
    Rectangle2D r = new Rectangle2D.Double(0.45, -0.55, 0.1, 0.1);
    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.CHORD);
    harness.check(!arc.contains(r));                     // check 22
   
    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.PIE);
    harness.check(arc.contains(r));                      // check 23
   
    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.OPEN);
    harness.check(!arc.contains(r));                     // check 24
     
    boolean pass = false;
    try
    {
      arc.contains((Rectangle2D) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);  // check 25
  }

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

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

import java.awt.geom.Arc2D;

/**
 * Tests the equals() method for the {@link Arc2D} 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)       
  {
    // Arc2D does NOT override equals()  
    Arc2D arc1 = new Arc2D.Double();
    Arc2D arc2 = new Arc2D.Double();
    harness.check(!arc1.equals(arc2));
    harness.check(!arc1.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.Arc2D;

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

import java.awt.geom.Arc2D;
import java.awt.geom.Rectangle2D;

/**
 * Tests the getBounds2D() method of the {@link Arc2D} 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)      
  {
    Arc2D arc = new Arc2D.Double();
    Rectangle2D b = arc.getBounds2D();
    harness.check(b.getX(), 0.0);
    harness.check(b.getY(), 0.0);
    harness.check(b.getWidth(), 0.0);
    harness.check(b.getHeight(), 0.0);
  
    arc = new Arc2D.Double(
      new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0), 90, 90, Arc2D.PIE
    );
    b = arc.getBounds2D();
    harness.check(b.getX(), 0.0);
    harness.check(b.getY(), 0.0);
    harness.check(b.getWidth(), 0.5);
    harness.check(b.getHeight(), 0.5);
  }

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

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

import java.awt.geom.Arc2D;
import java.awt.geom.Point2D;

/**
 * Tests the getEndPoint() method of the {@link Arc2D} class.
 */
public class getEndPoint implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    Arc2D arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.PIE);
    Point2D p = arc.getEndPoint();
    harness.check(p.getX(), 0.0);
    harness.check(p.getY(), -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.Arc2D;

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

import java.awt.geom.Arc2D;
import java.awt.geom.PathIterator;

/**
 * Tests the getPathIterator() method of the {@link Arc2D} class.
 */
public class getPathIterator implements Testlet {

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    double[] c = new double[6];
    Arc2D arc1 = new Arc2D.Double(1.0, 2.0, 3.0, 4.0, 0.0, 90.0, Arc2D.PIE);
    PathIterator iterator = arc1.getPathIterator(null);
    harness.check(!iterator.isDone());
    int segType = iterator.currentSegment(c);
    harness.check(segType == PathIterator.SEG_MOVETO);
    harness.check(c[0], 4.0);
    harness.check(c[1], 4.0);
    harness.check(!iterator.isDone());
    iterator.next();
    segType = iterator.currentSegment(c);
    harness.check(segType == PathIterator.SEG_CUBICTO);
    harness.check(c[0], 4.0);
    harness.check(c[1], 2.8954305003384135);
    harness.check(c[2], 3.3284271247461903);
    harness.check(c[3], 2.0);
    harness.check(c[4], 2.5);
    harness.check(c[5], 2.0);
    iterator.next();
    segType = iterator.currentSegment(c);
    harness.check(segType == PathIterator.SEG_LINETO);
    harness.check(c[0], 2.5);
    harness.check(c[1], 4.0);
    iterator.next();
    segType = iterator.currentSegment(c);
    harness.check(segType == PathIterator.SEG_CLOSE);
    iterator.next();
    harness.check(iterator.isDone());
  }

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

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

import java.awt.geom.Arc2D;
import java.awt.geom.Point2D;

/**
 * Tests the getStartPoint() method of the {@link Arc2D} class.
 */
public class getStartPoint implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    Arc2D arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.PIE);
    Point2D p = arc.getStartPoint();
    harness.check(p.getX(), 1.0);
    harness.check(p.getY(), 0.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.Arc2D;

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

import java.awt.geom.Arc2D;
import java.awt.geom.Rectangle2D;

/**
 * Tests the intersects() method of the {@link Arc2D} 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)      
  {
    Arc2D arc = new Arc2D.Double();
    harness.check(!arc.intersects(0.0, 0.0, 0.0, 0.0));
    harness.check(!arc.intersects(1.0, 2.0, 3.0, 4.0));

    arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.PIE);
    harness.check(arc.intersects(-1.0, 0.0, 1.0, 1.0));
    harness.check(arc.intersects(-1.0, -1.0, 1.0, 1.0));
    harness.check(arc.intersects(0.0, 0.0, 1.0, 1.0));
    harness.check(arc.intersects(0.0, -1.0, 1.0, 1.0));
    harness.check(!arc.intersects(5.0, 5.0, 1.0, 1.0));
    
    arc = new Arc2D.Double();
    harness.check(!arc.intersects(new Rectangle2D.Double(0.0, 0.0, 0.0, 0.0)));
    boolean pass = false;
    try {
        arc.intersects(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.Arc2D;

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

import java.awt.geom.Arc2D;

/**
 * Tests the isEmpty() method of the {@link Arc2D} 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)      
  {
    Arc2D arc = new Arc2D.Double();
    harness.check(arc.isEmpty());
      
    arc = new Arc2D.Double(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, Arc2D.CHORD);
    harness.check(!arc.isEmpty());
    arc = new Arc2D.Double(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, Arc2D.PIE);
    harness.check(!arc.isEmpty());
    arc = new Arc2D.Double(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, Arc2D.OPEN);
    harness.check(!arc.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.Arc2D;

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

import java.awt.geom.Arc2D;

/**
 * Tests the setAngleExtent() method of the {@link Arc2D} class.
 */
public class setAngleExtent implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    // setAngleExtent(double)
    Arc2D arc = new Arc2D.Double(0.0, 0.0, 1.0, 1.0, 0.0, 90.0, Arc2D.PIE);
    arc.setAngleExtent(85.0);
    harness.check(arc.getAngleExtent(), 85.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.Arc2D;

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

import java.awt.geom.Arc2D;
import java.awt.geom.Point2D;

/**
 * Tests the setAngles() method of the {@link Arc2D} class.
 */
public class setAngles implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    // setAngles(double, double, double, double)
    Arc2D arc = new Arc2D.Double(-1.0, -1.0, 2.0, 2.0, 0.0, 90.0, Arc2D.PIE);
    arc.setAngles(1.0, -1.0, -1.0, -1.0);
    harness.check(arc.getAngleStart(), 45.0);
    harness.check(arc.getAngleExtent(), 90.0);
   
    // setAngleStart(Point2D, Point2D)
    arc.setAngles(new Point2D.Double(1.0, 1.0), new Point2D.Double(-1.0, 1.0));
    harness.check(arc.getAngleStart(), -45.0);
    harness.check(arc.getAngleExtent(), 270.0);
    
    boolean pass = false;
    try
    {
      arc.setAngles(null, new Point2D.Double(-1.0, 1.0));
    }
    catch (NullPointerException e) 
    {
      pass = true;
    }
    harness.check(pass);
    
    pass = false;
    try
    {
      arc.setAngles(new Point2D.Double(-1.0, 1.0), 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.Arc2D;

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

import java.awt.geom.Arc2D;
import java.awt.geom.Point2D;

/**
 * Tests the setAngleStart() method of the {@link Arc2D} class.
 */
public class setAngleStart implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    // setAngleStart(double)
    Arc2D arc = new Arc2D.Double(0.0, 0.0, 1.0, 1.0, 0.0, 90.0, Arc2D.PIE);
    arc.setAngleStart(85.0);
    harness.check(arc.getAngleStart(), 85.0);
    
    // setAngleStart(Point2D)
    arc.setAngleStart(new Point2D.Double(1.0, 1.0));
    harness.check(arc.getAngleStart(), -45.0);
    boolean pass = false;
    try
    {
      arc.setAngleStart(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.Arc2D;

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

import java.awt.geom.Arc2D;

/**
 * Tests the setArcByCenter() method of the {@link Arc2D} class.
 */
public class setArcByCenter implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    Arc2D arc1 = new Arc2D.Double();
    arc1.setArcByCenter(1.0, 2.0, 3.0, 4.0, 5.0, Arc2D.PIE);
    harness.check(arc1.getX(), -2.0);
    harness.check(arc1.getY(), -1.0);
    harness.check(arc1.getWidth(), 6.0);
    harness.check(arc1.getHeight(), 6.0);
    harness.check(arc1.getAngleStart(), 4.0);
    harness.check(arc1.getAngleExtent(), 5.0);
    harness.check(arc1.getArcType() == Arc2D.PIE);
  
    // check for illegal closure type
    boolean pass = false;
    try 
    {
      arc1.setArcByCenter(1.0, 2.0, 3.0, 4.0, 5.0, 99);
    }
    catch (IllegalArgumentException 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.Arc2D;

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

import java.awt.geom.Arc2D;
import java.awt.geom.Point2D;

/**
 * Tests the setArcByTangent() method of the {@link Arc2D} class.
 */
public class setArcByTangent implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    Arc2D arc = new Arc2D.Double();
    arc.setArcByTangent(
      new Point2D.Double(10.0, 0.0), 
      new Point2D.Double(0.0, 0.0),
      new Point2D.Double(0.0, 10.0),
      1.0
    );
    harness.check(arc.getAngleStart(), 90.0);
    harness.check(arc.getAngleExtent(), 90.0);
    
    harness.checkPoint("Null arguments");
    testNullArguments(harness);
  }
  
  private void testNullArguments(TestHarness harness) 
  {
    boolean pass = false;
    Arc2D arc = new Arc2D.Double();
    try 
    {
      arc.setArcByTangent(
        null, 
        new Point2D.Double(0.0, 0.0),
        new Point2D.Double(0.0, 10.0),
        1.0
      );
    }
    catch (NullPointerException e) 
    {
      pass = true;
    }
    harness.check(pass);
    
    pass = false;
    try 
    {
      arc.setArcByTangent(
        new Point2D.Double(10.0, 0.0),
        null,
        new Point2D.Double(0.0, 10.0),
        1.0
      );
    }
    catch (NullPointerException e) 
    {
      pass = true;
    }
    harness.check(pass);

    pass = false;
    try 
    {
      arc.setArcByTangent(
        new Point2D.Double(10.0, 0.0),
        new Point2D.Double(0.0, 10.0),
        null,
        1.0
      );
    }
    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.Arc2D;

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

import java.awt.Dimension;
import java.awt.geom.Arc2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

/**
 * Tests the setArc() method of the {@link Arc2D} class.
 */
public class setArc implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    // setArc(Arc2D)
    Arc2D arc1 = new Arc2D.Double();
    Arc2D arc2 = new Arc2D.Double(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, Arc2D.PIE);
    arc1.setArc(arc2);
    harness.check(arc1.getX(), 1.0);
    harness.check(arc1.getY(), 2.0);
    harness.check(arc1.getWidth(), 3.0);
    harness.check(arc1.getHeight(), 4.0);
    harness.check(arc1.getAngleStart(), 5.0);
    harness.check(arc1.getAngleExtent(), 6.0);
    harness.check(arc1.getArcType() == Arc2D.PIE);
    
    boolean pass = false;
    try 
    {
      arc1.setArc(null);
    }
    catch (NullPointerException e) 
    {
      pass = true;
    }
    harness.check(pass);
    
    // setArc(double, double, double, double, double, double, int)
    arc1 = new Arc2D.Double();
    arc1.setArc(6.0, 5.0, 4.0, 3.0, 2.0, 1.0, Arc2D.OPEN);
    harness.check(arc1.getX(), 6.0);
    harness.check(arc1.getY(), 5.0);
    harness.check(arc1.getWidth(), 4.0);
    harness.check(arc1.getHeight(), 3.0);
    harness.check(arc1.getAngleStart(), 2.0);
    harness.check(arc1.getAngleExtent(), 1.0);
    harness.check(arc1.getArcType() == Arc2D.OPEN);
    
    // setArc(Point2D, Dimension2D, double, double, int)
    arc1 = new Arc2D.Double();
    arc1.setArc(
      new Point2D.Double(1.0, 2.0), 
      new Dimension(3, 4), 
      5.0, 6.0, Arc2D.CHORD
    );
    harness.check(arc1.getX(), 1.0);
    harness.check(arc1.getY(), 2.0);
    harness.check(arc1.getWidth(), 3.0);
    harness.check(arc1.getHeight(), 4.0);
    harness.check(arc1.getAngleStart(), 5.0);
    harness.check(arc1.getAngleExtent(), 6.0);
    harness.check(arc1.getArcType() == Arc2D.CHORD);
    
    pass = false;
    try 
    {
      arc1.setArc(null, new Dimension(3, 4), 5.0, 6.0, Arc2D.CHORD);
    }
    catch (NullPointerException e) 
    {
      pass = true;
    }
    harness.check(pass);
    
    pass = false;
    try 
    {
      arc1.setArc(new Point2D.Double(1.0, 2.0), null, 5.0, 6.0, Arc2D.CHORD);
    }
    catch (NullPointerException e) 
    {
      pass = true;
    }
    harness.check(pass);
    
    // setArc(Rectangle2D, double, double, int)
    arc1 = new Arc2D.Double();
    arc1.setArc(
      new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
      5.0, 6.0, Arc2D.OPEN
    );
    harness.check(arc1.getX(), 1.0);
    harness.check(arc1.getY(), 2.0);
    harness.check(arc1.getWidth(), 3.0);
    harness.check(arc1.getHeight(), 4.0);
    harness.check(arc1.getAngleStart(), 5.0);
    harness.check(arc1.getAngleExtent(), 6.0);
    harness.check(arc1.getArcType() == Arc2D.OPEN);
    
    pass = false;
    try 
    {
      arc1.setArc(null, 5.0, 6.0, Arc2D.CHORD);
    }
    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.Arc2D;

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

import java.awt.geom.Arc2D;

/**
 * Tests the setArcType() method in the {@link Arc2D} class.
 */
public class setArcType implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Arc2D arc = new Arc2D.Double();
    arc.setArcType(Arc2D.OPEN);
    harness.check(arc.getArcType() == Arc2D.OPEN);
    arc.setArcType(Arc2D.CHORD);
    harness.check(arc.getArcType() == Arc2D.CHORD);
    arc.setArcType(Arc2D.PIE);
    harness.check(arc.getArcType() == Arc2D.PIE);
    
    boolean pass = false;
    try {
      arc.setArcType(99);
    }
    catch (IllegalArgumentException 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.Arc2D;

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

import java.awt.geom.Arc2D;

/**
 * Tests the setFrame() method of the {@link Arc2D} class.
 */
public class setFrame implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    Arc2D arc = new Arc2D.Double(0.0, 0.0, 1.0, 1.0, 0.0, 90.0, Arc2D.PIE);
    arc.setFrame(1.0, 2.0, 3.0, 4.0);
    harness.check(arc.getX(), 1.0);
    harness.check(arc.getY(), 2.0);
    harness.check(arc.getWidth(), 3.0);
    harness.check(arc.getHeight(), 4.0);
  }

}

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