* FYI: Polygon.getPathIterator() test
@ 2006-06-14 22:31 David Gilbert
0 siblings, 0 replies; only message in thread
From: David Gilbert @ 2006-06-14 22:31 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 218 bytes --]
I added a test for the getPathIterator() method in the Polygon class:
2006-06-14 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/java/awt/Polygon/getPathIterator.java: New test.
Regards,
Dave
[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 7104 bytes --]
Index: gnu/testlet/java/awt/Polygon/getPathIterator.java
===================================================================
RCS file: gnu/testlet/java/awt/Polygon/getPathIterator.java
diff -N gnu/testlet/java/awt/Polygon/getPathIterator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/Polygon/getPathIterator.java 14 Jun 2006 22:27:36 -0000
@@ -0,0 +1,194 @@
+/* getPathIterator.java -- some checks for the getPathIterator() method in the
+ Polygon class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: 1.2
+
+package gnu.testlet.java.awt.Polygon;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Polygon;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+
+public class getPathIterator implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ test1(harness);
+ test2(harness);
+ }
+
+ public void test1(TestHarness harness)
+ {
+ harness.checkPoint("(AffineTransform)");
+ Polygon p = new Polygon(new int[] {0, 1, 1, 0},
+ new int[] {0, 0, 1, 1}, 4);
+
+ // test with no tranform...
+ PathIterator pi = p.getPathIterator(null);
+ harness.check(pi.getWindingRule(), PathIterator.WIND_EVEN_ODD);
+ double[] coords = new double[6];
+ int t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_MOVETO);
+ harness.check(coords[0], 0.0);
+ harness.check(coords[1], 0.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 1.0);
+ harness.check(coords[1], 0.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 1.0);
+ harness.check(coords[1], 1.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 0.0);
+ harness.check(coords[1], 1.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_CLOSE);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ harness.check(pi.isDone(), true);
+
+ // test with tranform...
+ AffineTransform trans = AffineTransform.getTranslateInstance(10.0, 11.0);
+ pi = p.getPathIterator(trans);
+ harness.check(pi.getWindingRule(), PathIterator.WIND_EVEN_ODD);
+ coords = new double[6];
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_MOVETO);
+ harness.check(coords[0], 10.0);
+ harness.check(coords[1], 11.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 11.0);
+ harness.check(coords[1], 11.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 11.0);
+ harness.check(coords[1], 12.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 10.0);
+ harness.check(coords[1], 12.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_CLOSE);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ harness.check(pi.isDone(), true);
+
+ }
+
+ public void test2(TestHarness harness)
+ {
+ harness.checkPoint("(AffineTransform, double)");
+ Polygon p = new Polygon(new int[] {0, 1, 1, 0},
+ new int[] {0, 0, 1, 1}, 4);
+
+ // test with no tranform...
+ PathIterator pi = p.getPathIterator(null, 1.0);
+ harness.check(pi.getWindingRule(), PathIterator.WIND_EVEN_ODD);
+ double[] coords = new double[6];
+ int t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_MOVETO);
+ harness.check(coords[0], 0.0);
+ harness.check(coords[1], 0.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 1.0);
+ harness.check(coords[1], 0.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 1.0);
+ harness.check(coords[1], 1.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 0.0);
+ harness.check(coords[1], 1.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_CLOSE);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ harness.check(pi.isDone(), true);
+
+ // test with tranform...
+ AffineTransform trans = AffineTransform.getTranslateInstance(10.0, 11.0);
+ pi = p.getPathIterator(trans, 1.0);
+ harness.check(pi.getWindingRule(), PathIterator.WIND_EVEN_ODD);
+ coords = new double[6];
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_MOVETO);
+ harness.check(coords[0], 10.0);
+ harness.check(coords[1], 11.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 11.0);
+ harness.check(coords[1], 11.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 11.0);
+ harness.check(coords[1], 12.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_LINETO);
+ harness.check(coords[0], 10.0);
+ harness.check(coords[1], 12.0);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ t = pi.currentSegment(coords);
+ harness.check(t, PathIterator.SEG_CLOSE);
+ harness.check(pi.isDone(), false);
+ pi.next();
+ harness.check(pi.isDone(), true);
+ }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-06-14 22:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-14 22:31 FYI: Polygon.getPathIterator() test David Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).