This is the mail archive of the mauve-patches@sourceware.org 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]

FYI: New Vector tests


I added 2 tests for Vector that check that removeAll() and retainAll() accept null arguments when the Vector is empty.

2006-08-15 Roman Kennke <kennke@aicas.com>

	* gnu/testlet/java/util/Vector/removeAll.java: New test.
	* gnu/testlet/java/util/Vector/retainAll.java: New test.


/Roman
Index: gnu/testlet/java/util/Vector/retainAll.java
===================================================================
RCS file: gnu/testlet/java/util/Vector/retainAll.java
diff -N gnu/testlet/java/util/Vector/retainAll.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/util/Vector/retainAll.java	15 Aug 2006 09:46:33 -0000
@@ -0,0 +1,63 @@
+/* retainAll.java -- Checks functionality in retainAll()
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.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.java.util.Vector;
+
+import java.util.Vector;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class retainAll implements Testlet
+{
+
+  public void test(TestHarness harness)
+  {
+    testNull(harness);
+  }
+
+  /**
+   * Checks if and when null arguments to removeAll() are allowed.
+   *
+   * @param h the test harness
+   */
+  private void testNull(TestHarness h)
+  {
+    // Check empty vector.
+    Vector v = new Vector();
+    v.removeAll(null);
+    h.check(true); // If we got here, there was no NPE.
+
+    // Check non-empty vector.
+    v.add(new Object());
+    try
+      {
+        v.retainAll(null);
+        h.fail("NPE should be thrown");
+      }
+    catch (NullPointerException ex)
+      {
+        h.check(true);
+      }
+  }
+}
Index: gnu/testlet/java/util/Vector/removeAll.java
===================================================================
RCS file: gnu/testlet/java/util/Vector/removeAll.java
diff -N gnu/testlet/java/util/Vector/removeAll.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/util/Vector/removeAll.java	15 Aug 2006 09:46:33 -0000
@@ -0,0 +1,63 @@
+/* removeAll.java -- Checks some functionality in Vector.removeAll()
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.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.java.util.Vector;
+
+import java.util.Vector;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class removeAll implements Testlet
+{
+
+  public void test(TestHarness harness)
+  {
+    testNull(harness);
+  }
+
+  /**
+   * Checks if and when null arguments to removeAll() are allowed.
+   *
+   * @param h the test harness
+   */
+  private void testNull(TestHarness h)
+  {
+    // Check empty vector.
+    Vector v = new Vector();
+    v.removeAll(null);
+    h.check(true); // If we got here, there was no NPE.
+
+    // Check non-empty vector.
+    v.add(new Object());
+    try
+      {
+        v.removeAll(null);
+        h.fail("NPE should be thrown");
+      }
+    catch (NullPointerException ex)
+      {
+        h.check(true);
+      }
+  }
+}

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