This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: Kernel.java - new tests
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Fri, 21 Jul 2006 05:08:33 +0100
- Subject: FYI: Kernel.java - new tests
This patch (committed) adds some tests for the Kernel class:
2006-07-21 David Gilbert <david.gilbet@object-refinery.com>
* gnu/testlet/java/awt/image/Kernel/constructor.java: New test,
* gnu/testlet/java/awt/image/Kernel/getHeight.java: New test,
* gnu/testlet/java/awt/image/Kernel/getKernelData.java: New test,
* gnu/testlet/java/awt/image/Kernel/getWidth.java: New test,
* gnu/testlet/java/awt/image/Kernel/getXOrigin.java: New test,
* gnu/testlet/java/awt/image/Kernel/getYOrigin.java: New test.
Regards,
Dave
Index: gnu/testlet/java/awt/image/Kernel/check.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/awt/image/Kernel/check.java,v
retrieving revision 1.3
diff -u -r1.3 check.java
--- gnu/testlet/java/awt/image/Kernel/check.java 14 Aug 2004 21:29:52 -0000 1.3
+++ gnu/testlet/java/awt/image/Kernel/check.java 21 Jul 2006 03:04:39 -0000
@@ -21,8 +21,8 @@
package gnu.testlet.java.awt.image.Kernel;
-import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
import java.awt.image.Kernel;
Index: gnu/testlet/java/awt/image/Kernel/constructor.java
===================================================================
RCS file: gnu/testlet/java/awt/image/Kernel/constructor.java
diff -N gnu/testlet/java/awt/image/Kernel/constructor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/Kernel/constructor.java 21 Jul 2006 03:04:39 -0000
@@ -0,0 +1,92 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301 USA.
+
+package gnu.testlet.java.awt.image.Kernel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.Kernel;
+
+/**
+ * Some checks for the constructor in the {@link Kernel} class.
+*/
+public class constructor implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ float[] d1 = new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
+ 9f, 10f, 11f, 12f, 13f, 14f, 15f};
+ Kernel k1 = new Kernel(3, 5, d1);
+ harness.check(k1.getWidth(), 3);
+ harness.check(k1.getHeight(), 5);
+ harness.check(k1.getXOrigin(), 1);
+ harness.check(k1.getYOrigin(), 2);
+
+ // changing source data array shouldn't change the kernel
+ d1[0] = Float.NaN;
+ float[] d2 = k1.getKernelData(null);
+ harness.check(!Float.isNaN(d2[0]));
+
+ // try negative width
+ boolean pass = false;
+ try
+ {
+ k1 = new Kernel(-1, 2, new float[] {1f, 2f});
+ }
+ catch (NegativeArraySizeException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try negative height
+ pass = false;
+ try
+ {
+ k1 = new Kernel(1, -2, new float[] {1f, 2f});
+ }
+ catch (NegativeArraySizeException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try null array
+ pass = false;
+ try
+ {
+ k1 = new Kernel(1, 2, null);
+ }
+ catch (NullPointerException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ }
+
+}
+
Index: gnu/testlet/java/awt/image/Kernel/getHeight.java
===================================================================
RCS file: gnu/testlet/java/awt/image/Kernel/getHeight.java
diff -N gnu/testlet/java/awt/image/Kernel/getHeight.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/Kernel/getHeight.java 21 Jul 2006 03:04:39 -0000
@@ -0,0 +1,46 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301 USA.
+
+
+package gnu.testlet.java.awt.image.Kernel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.Kernel;
+
+/**
+ * Some checks for the getHeight() method in the {@link Kernel} class.
+ */
+public class getHeight implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ Kernel k1 = new Kernel(1, 2, new float[] {1f, 2f});
+ harness.check(k1.getHeight(), 2);
+ }
+
+}
+
Index: gnu/testlet/java/awt/image/Kernel/getKernelData.java
===================================================================
RCS file: gnu/testlet/java/awt/image/Kernel/getKernelData.java
diff -N gnu/testlet/java/awt/image/Kernel/getKernelData.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/Kernel/getKernelData.java 21 Jul 2006 03:04:39 -0000
@@ -0,0 +1,64 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301 USA.
+
+package gnu.testlet.java.awt.image.Kernel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.Kernel;
+import java.util.Arrays;
+
+/**
+ * Some checks for the getKernelData() method in the {@link Kernel} class.
+ */
+public class getKernelData implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ float[] d1 = new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
+ 9f, 10f, 11f, 12f, 13f, 14f, 15f};
+ Kernel k1 = new Kernel(3, 5, d1);
+
+ float[] d2 = k1.getKernelData(null);
+ harness.check(d1 != d2);
+ harness.check(Arrays.equals(d1, d2));
+
+ // try argument length too short
+ boolean pass = false;
+ try
+ {
+ d2 = new float[14];
+ d2 = k1.getKernelData(d2);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+
+}
+
Index: gnu/testlet/java/awt/image/Kernel/getWidth.java
===================================================================
RCS file: gnu/testlet/java/awt/image/Kernel/getWidth.java
diff -N gnu/testlet/java/awt/image/Kernel/getWidth.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/Kernel/getWidth.java 21 Jul 2006 03:04:39 -0000
@@ -0,0 +1,46 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301 USA.
+
+
+package gnu.testlet.java.awt.image.Kernel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.Kernel;
+
+/**
+ * Some checks for the getWidth() method in the {@link Kernel} class.
+ */
+public class getWidth implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ Kernel k1 = new Kernel(1, 2, new float[] {1f, 2f});
+ harness.check(k1.getWidth(), 1);
+ }
+
+}
+
Index: gnu/testlet/java/awt/image/Kernel/getXOrigin.java
===================================================================
RCS file: gnu/testlet/java/awt/image/Kernel/getXOrigin.java
diff -N gnu/testlet/java/awt/image/Kernel/getXOrigin.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/Kernel/getXOrigin.java 21 Jul 2006 03:04:39 -0000
@@ -0,0 +1,52 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301 USA.
+
+package gnu.testlet.java.awt.image.Kernel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.Kernel;
+
+/**
+ * Some checks for the getXOrigin() method in the {@link Kernel} class.
+ */
+public class getXOrigin implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ Kernel k1 = new Kernel(3, 4, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
+ 9f, 10f, 11f, 12f});
+ harness.check(k1.getXOrigin(), 1);
+ Kernel k2 = new Kernel(4, 3, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
+ 9f, 10f, 11f, 12f});
+ harness.check(k2.getXOrigin(), 1);
+ Kernel k3 = new Kernel(5, 2, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
+ 9f, 10f});
+ harness.check(k3.getXOrigin(), 2);
+ }
+
+}
+
Index: gnu/testlet/java/awt/image/Kernel/getYOrigin.java
===================================================================
RCS file: gnu/testlet/java/awt/image/Kernel/getYOrigin.java
diff -N gnu/testlet/java/awt/image/Kernel/getYOrigin.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/Kernel/getYOrigin.java 21 Jul 2006 03:04:39 -0000
@@ -0,0 +1,53 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301 USA.
+
+
+package gnu.testlet.java.awt.image.Kernel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.Kernel;
+
+/**
+ * Some checks for the getYOrigin() method in the {@link Kernel} class.
+ */
+public class getYOrigin implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ Kernel k1 = new Kernel(3, 4, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
+ 9f, 10f, 11f, 12f});
+ harness.check(k1.getYOrigin(), 1);
+ Kernel k2 = new Kernel(4, 3, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
+ 9f, 10f, 11f, 12f});
+ harness.check(k2.getYOrigin(), 1);
+ Kernel k3 = new Kernel(5, 2, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
+ 9f, 10f});
+ harness.check(k3.getYOrigin(), 0);
+ }
+
+}
+