This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: SizeSequence - new tests
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Tue, 16 May 2006 21:33:14 +0100
- Subject: FYI: SizeSequence - new tests
This patch (committed) adds some tests for the SizeSequence class:
2006-05-16 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/javax/swing/SizeSequence/constructors.java: New test,
* gnu/testlet/javax/swing/SizeSequence/getIndex.java: New test,
* gnu/testlet/javax/swing/SizeSequence/getSize.java: New test,
* gnu/testlet/javax/swing/SizeSequence/getSizes.java: New test,
* gnu/testlet/javax/swing/SizeSequence/insertEntries.java: New test,
* gnu/testlet/javax/swing/SizeSequence/removeEntries.java: New test,
* gnu/testlet/javax/swing/SizeSequence/setSize.java: New test,
* gnu/testlet/javax/swing/SizeSequence/setSizes.java: New test.
Regards,
Dave
Index: gnu/testlet/javax/swing/SizeSequence/constructors.java
===================================================================
RCS file: gnu/testlet/javax/swing/SizeSequence/constructors.java
diff -N gnu/testlet/javax/swing/SizeSequence/constructors.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SizeSequence/constructors.java 16 May 2006 20:30:00 -0000
@@ -0,0 +1,114 @@
+/* constructors.java -- some checks for the constructors in the SizeSequence
+ 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: JDK1.2
+
+package gnu.testlet.javax.swing.SizeSequence;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Arrays;
+
+import javax.swing.SizeSequence;
+
+public class constructors implements Testlet
+{
+
+ public void test(TestHarness harness)
+ {
+ testConstructor1(harness);
+ testConstructor2(harness);
+ testConstructor3(harness);
+ testConstructor4(harness);
+ }
+
+ private void testConstructor1(TestHarness harness)
+ {
+ harness.checkPoint("()");
+ SizeSequence s = new SizeSequence();
+ harness.check(Arrays.equals(s.getSizes(), new int[0]));
+ }
+
+ private void testConstructor2(TestHarness harness)
+ {
+ harness.checkPoint("(int)");
+
+ SizeSequence s = new SizeSequence(3);
+ harness.check(Arrays.equals(s.getSizes(), new int[3]));
+
+ // try negative
+ boolean pass = false;
+ try
+ {
+ s = new SizeSequence(-1);
+ }
+ catch (NegativeArraySizeException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+
+ private void testConstructor3(TestHarness harness)
+ {
+ harness.checkPoint("(int, int)");
+ SizeSequence s = new SizeSequence(3, 5);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {5, 5, 5}));
+
+ // try negative
+ boolean pass = false;
+ try
+ {
+ s = new SizeSequence(-1, 5);
+ }
+ catch (NegativeArraySizeException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+
+ private void testConstructor4(TestHarness harness)
+ {
+ harness.checkPoint("(int[])");
+ int[] sizes = new int[] {1, 2, 3};
+ SizeSequence s = new SizeSequence(sizes);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {1, 2, 3}));
+ sizes[0] = 99;
+ harness.check(Arrays.equals(s.getSizes(), new int[] {1, 2, 3}));
+
+ // try null
+ boolean pass = false;
+ try
+ {
+ s = new SizeSequence(null);
+ }
+ catch (NullPointerException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+
+}
Index: gnu/testlet/javax/swing/SizeSequence/getIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/SizeSequence/getIndex.java
diff -N gnu/testlet/javax/swing/SizeSequence/getIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SizeSequence/getIndex.java 16 May 2006 20:30:00 -0000
@@ -0,0 +1,54 @@
+/* getIndex.java -- some checks for the getIndex() method in the SizeSequence
+ 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: JDK1.2
+
+package gnu.testlet.javax.swing.SizeSequence;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SizeSequence;
+
+public class getIndex implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ SizeSequence s = new SizeSequence(new int[] {1, 2, 3});
+ harness.check(s.getIndex(0), 0);
+ harness.check(s.getIndex(1), 1);
+ harness.check(s.getIndex(2), 1);
+ harness.check(s.getIndex(3), 2);
+ harness.check(s.getIndex(4), 2);
+ harness.check(s.getIndex(5), 2);
+ harness.check(s.getIndex(6), 3);
+ harness.check(s.getIndex(7), 3);
+ harness.check(s.getIndex(99), 3);
+ harness.check(s.getIndex(-1), 0);
+
+ s = new SizeSequence();
+ harness.check(s.getIndex(-1), 0);
+ harness.check(s.getIndex(0), 0);
+ harness.check(s.getIndex(1), 0);
+ }
+}
Index: gnu/testlet/javax/swing/SizeSequence/getSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/SizeSequence/getSize.java
diff -N gnu/testlet/javax/swing/SizeSequence/getSize.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SizeSequence/getSize.java 16 May 2006 20:30:00 -0000
@@ -0,0 +1,41 @@
+/* getSize.java -- some checks for the getSize() method in the SizeSequence
+ 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: JDK1.2
+
+package gnu.testlet.javax.swing.SizeSequence;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SizeSequence;
+
+public class getSize implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ SizeSequence s = new SizeSequence(new int[] {1, 2, 3});
+ harness.check(s.getSize(0), 1);
+ harness.check(s.getSize(1), 2);
+ harness.check(s.getSize(2), 3);
+ }
+}
Index: gnu/testlet/javax/swing/SizeSequence/getSizes.java
===================================================================
RCS file: gnu/testlet/javax/swing/SizeSequence/getSizes.java
diff -N gnu/testlet/javax/swing/SizeSequence/getSizes.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SizeSequence/getSizes.java 16 May 2006 20:30:00 -0000
@@ -0,0 +1,48 @@
+/* getSizes.java -- some checks for the getSizes() method in the SizeSequence
+ 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: JDK1.2
+
+package gnu.testlet.javax.swing.SizeSequence;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Arrays;
+
+import javax.swing.SizeSequence;
+
+public class getSizes implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ int[] sizes = new int[] {1, 2, 3};
+ SizeSequence s = new SizeSequence(sizes);
+ int[] sizes2 = s.getSizes();
+ harness.check(Arrays.equals(sizes, sizes2)); // equal, but...
+ harness.check(sizes != sizes2); // ...not the same array
+
+ s = new SizeSequence();
+ harness.check(Arrays.equals(s.getSizes(), new int[0]));
+ }
+}
Index: gnu/testlet/javax/swing/SizeSequence/insertEntries.java
===================================================================
RCS file: gnu/testlet/javax/swing/SizeSequence/insertEntries.java
diff -N gnu/testlet/javax/swing/SizeSequence/insertEntries.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SizeSequence/insertEntries.java 16 May 2006 20:30:00 -0000
@@ -0,0 +1,51 @@
+/* insertEntries.java -- some checks for the insertEntries() method in the
+ SizeSequence 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: JDK1.2
+
+package gnu.testlet.javax.swing.SizeSequence;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Arrays;
+
+import javax.swing.SizeSequence;
+
+public class insertEntries implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ SizeSequence s = new SizeSequence();
+ s.insertEntries(0, 1, 1);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {1}));
+ s.insertEntries(1, 2, 2);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {1, 2, 2}));
+ s.insertEntries(0, 2, 3);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {3, 3, 1, 2, 2}));
+ s.insertEntries(0, 0, 99);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {3, 3, 1, 2, 2}));
+ s.insertEntries(4, 0, 99);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {3, 3, 1, 2, 2}));
+ }
+}
Index: gnu/testlet/javax/swing/SizeSequence/removeEntries.java
===================================================================
RCS file: gnu/testlet/javax/swing/SizeSequence/removeEntries.java
diff -N gnu/testlet/javax/swing/SizeSequence/removeEntries.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SizeSequence/removeEntries.java 16 May 2006 20:30:00 -0000
@@ -0,0 +1,54 @@
+/* removeEntries.java -- some checks for the removeEntries() method in the
+ SizeSequence 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: JDK1.2
+
+package gnu.testlet.javax.swing.SizeSequence;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Arrays;
+
+import javax.swing.SizeSequence;
+
+public class removeEntries implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ SizeSequence s = new SizeSequence(new int[] {1, 2, 3});
+ s.removeEntries(0, 0);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {1, 2, 3}));
+ s.removeEntries(2, 0);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {1, 2, 3}));
+ s.removeEntries(0, 2);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {3}));
+ s.removeEntries(0, 1);
+ harness.check(Arrays.equals(s.getSizes(), new int[0]));
+
+ s = new SizeSequence(new int[] {1, 2, 3, 4, 5});
+ s.removeEntries(3, 2);
+ harness.check(Arrays.equals(s.getSizes(), new int[] {1, 2, 3}));
+
+ }
+}
Index: gnu/testlet/javax/swing/SizeSequence/setSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/SizeSequence/setSize.java
diff -N gnu/testlet/javax/swing/SizeSequence/setSize.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SizeSequence/setSize.java 16 May 2006 20:30:00 -0000
@@ -0,0 +1,47 @@
+/* setSize.java -- some checks for the setSize() method in the SizeSequence
+ 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: JDK1.2
+
+package gnu.testlet.javax.swing.SizeSequence;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SizeSequence;
+
+public class setSize implements Testlet {
+
+ public void test(TestHarness harness)
+ {
+ SizeSequence s = new SizeSequence(new int[] {1, 2, 3});
+ s.setSize(0, 3);
+ harness.check(s.getSize(0), 3);
+
+ // the spec says that the behaviour for indices outside the bounds is
+ // unspecified. The following throw no exceptions, but that can't be
+ // relied upon...
+ s.setSize(-1, 3);
+ s.setSize(3, 3);
+ }
+}
Index: gnu/testlet/javax/swing/SizeSequence/setSizes.java
===================================================================
RCS file: gnu/testlet/javax/swing/SizeSequence/setSizes.java
diff -N gnu/testlet/javax/swing/SizeSequence/setSizes.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SizeSequence/setSizes.java 16 May 2006 20:30:00 -0000
@@ -0,0 +1,57 @@
+/* setSizes.java -- some checks for the setSizes() method in the SizeSequence
+ 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: JDK1.2
+
+package gnu.testlet.javax.swing.SizeSequence;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Arrays;
+
+import javax.swing.SizeSequence;
+
+public class setSizes implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ SizeSequence s = new SizeSequence();
+ int[] sizes = new int[] {1, 2, 3};
+ s.setSizes(sizes);
+ harness.check(Arrays.equals(s.getSizes(), sizes));
+ sizes[0] = 99;
+ harness.check(Arrays.equals(s.getSizes(), new int[] {1, 2, 3}));
+
+ boolean pass = false;
+ try
+ {
+ s.setSizes(null);
+ }
+ catch (NullPointerException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+}