tests/libjava-mauve/src/gnu/testlet/java/util/ArrayList/AcuniaArrayListTest.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 /* Copyright (C) 2001 ACUNIA
       
     2 
       
     3    This file is part of Mauve.
       
     4 
       
     5    Mauve is free software; you can redistribute it and/or modify
       
     6    it under the terms of the GNU General Public License as published by
       
     7    the Free Software Foundation; either version 2, or (at your option)
       
     8    any later version.
       
     9 
       
    10    Mauve is distributed in the hope that it will be useful,
       
    11    but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13    GNU General Public License for more details.
       
    14 
       
    15    You should have received a copy of the GNU General Public License
       
    16    along with Mauve; see the file COPYING.  If not, write to
       
    17    the Free Software Foundation, 59 Temple Place - Suite 330,
       
    18    Boston, MA 02111-1307, USA.
       
    19 */
       
    20 
       
    21 // Tags: JDK1.2
       
    22 
       
    23 package gnu.testlet.java.util.ArrayList;
       
    24 import gnu.testlet.Testlet;
       
    25 import gnu.testlet.TestHarness;
       
    26 
       
    27 import java.util.*;
       
    28 
       
    29 /**
       
    30 *  Written by ACUNIA. <br>
       
    31 *                        <br>
       
    32 *  this file contains test for ArrayList   <br>
       
    33 *  <br>
       
    34 *  It might be usefull to find out how the capacity evolves <br>
       
    35 *  --> this must be done with reflection ... (not done yet)
       
    36 */
       
    37 public class AcuniaArrayListTest extends ArrayList implements Testlet
       
    38 {
       
    39   protected TestHarness th;
       
    40 
       
    41   public AcuniaArrayListTest() { /* Empty constructor needed for TestLet */}
       
    42 
       
    43   public void test (TestHarness harness)
       
    44     {
       
    45        th = harness;
       
    46        test_ArrayList();
       
    47        test_get();
       
    48        test_ensureCapacity();
       
    49        test_trimToSize();
       
    50        test_add();
       
    51        test_addAll();
       
    52        test_clear();
       
    53        test_remove();
       
    54        test_set();
       
    55        test_contains();
       
    56        test_isEmpty();
       
    57        test_indexOf();
       
    58        test_size();
       
    59        test_lastIndexOf();
       
    60        test_toArray();
       
    61        test_clone();
       
    62        // extra
       
    63        test_removeRange();
       
    64        test_MC_iterator();
       
    65 
       
    66      }
       
    67 
       
    68   protected ArrayList buildAL() {
       
    69     Vector v = new Vector();
       
    70     v.add("a");     v.add("c");   v.add("u");   v.add("n");   v.add("i");   v.add("a");  v.add(null);
       
    71     v.add("a");     v.add("c");   v.add("u");   v.add("n");   v.add("i");   v.add("a");  v.add(null);
       
    72     return new ArrayList(v);
       
    73 
       
    74   }
       
    75 
       
    76 
       
    77 /**
       
    78 *   not implemented. <br>
       
    79 *   only ArrayList(Collection c) is tested
       
    80 */
       
    81   public void test_ArrayList(){
       
    82     th.checkPoint("arrayList(java.util.Collection)");
       
    83     Vector v = new Vector();
       
    84     ArrayList al = new ArrayList(v);
       
    85     th.check( al.isEmpty() , "no elements added");
       
    86     v.add("a");     v.add("c");   v.add("u");   v.add("n");   v.add("i");   v.add("a");  v.add(null);
       
    87     al = new ArrayList(v);
       
    88     th.check(v.equals(al) , "check if everything is OK");
       
    89     try {
       
    90     	new ArrayList(null);
       
    91     	th.fail("should throw a NullPointerException");
       
    92     	}
       
    93     catch(NullPointerException npe) { th.check(true); }
       
    94   }
       
    95 
       
    96 /**
       
    97 * implemented. <br>
       
    98 *
       
    99 */
       
   100   public void test_get(){
       
   101     th.checkPoint("get(int)java.lang.Object");
       
   102     ArrayList al = new ArrayList();
       
   103     try {
       
   104         al.get(0);
       
   105         th.fail("should throw an IndexOutOfBoundsException -- 1");
       
   106         }
       
   107     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   108     try {
       
   109         al.get(-1);
       
   110         th.fail("should throw an IndexOutOfBoundsException -- 2");
       
   111         }
       
   112     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   113     al = buildAL();
       
   114     try {
       
   115         al.get(14);
       
   116         th.fail("should throw an IndexOutOfBoundsException -- 3");
       
   117         }
       
   118     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   119     try {
       
   120         al.get(-1);
       
   121         th.fail("should throw an IndexOutOfBoundsException -- 4");
       
   122         }
       
   123     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   124     th.check("a".equals(al.get(0)) , "checking returnvalue -- 1");
       
   125     th.check("c".equals(al.get(1)) , "checking returnvalue -- 2");
       
   126     th.check("u".equals(al.get(2)) , "checking returnvalue -- 3");
       
   127     th.check("a".equals(al.get(5)) , "checking returnvalue -- 4");
       
   128     th.check("a".equals(al.get(7)) , "checking returnvalue -- 5");
       
   129     th.check("c".equals(al.get(8)) , "checking returnvalue -- 6");
       
   130     th.check("u".equals(al.get(9)) , "checking returnvalue -- 7");
       
   131     th.check("a".equals(al.get(12)), "checking returnvalue -- 8");
       
   132     th.check( null == al.get(6)    , "checking returnvalue -- 9");
       
   133     th.check( null == al.get(13)   , "checking returnvalue -- 10");
       
   134   }
       
   135 
       
   136 /**
       
   137 * implemented. <br>
       
   138 * => might need extra testing --> using reflection ...
       
   139 */
       
   140   public void test_ensureCapacity(){
       
   141     th.checkPoint("ensureCapacity(int)");
       
   142     ArrayList al = buildAL();
       
   143     al.ensureCapacity(4);
       
   144     th.check(al.size() == 14 , "make sure the list cannot be downsized !");
       
   145 
       
   146   }
       
   147 /**
       
   148 *   not implemented. <br>
       
   149 *
       
   150 */
       
   151   public void test_trimToSize(){
       
   152     th.checkPoint("trimToSize()");
       
   153 
       
   154   }
       
   155 /**
       
   156 * implemented. <br>
       
   157 *
       
   158 */
       
   159   public void test_add(){
       
   160     th.checkPoint("add(int,java.lang.Object)void");
       
   161     ArrayList al = new ArrayList();
       
   162     try {
       
   163         al.add(-1,"a");
       
   164         th.fail("should throw an IndexOutOfBoundsException -- 1");
       
   165         }
       
   166     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   167     try {
       
   168         al.add(1,"a");
       
   169         th.fail("should throw an IndexOutOfBoundsException -- 2");
       
   170         }
       
   171     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   172     al.add(0,"a");
       
   173     al.add(1,"c");
       
   174     al.add(2,"u");
       
   175     al.add(1,null);
       
   176     th.check("a".equals(al.get(0))&& null==al.get(1) && "c".equals(al.get(2)) && "u".equals(al.get(3)) , "checking add ...");
       
   177 
       
   178     th.checkPoint("add(java.lang.Object)boolean");
       
   179     al = new ArrayList();
       
   180     th.check(al.add("a") , "checking return value -- 1");
       
   181     th.check(al.add("c") , "checking return value -- 2");
       
   182     th.check(al.add("u") , "checking return value -- 3");
       
   183     th.check(al.add("n") , "checking return value -- 4");
       
   184     th.check(al.add("i") , "checking return value -- 5");
       
   185     th.check(al.add("a") , "checking return value -- 6");
       
   186     th.check(al.add(null) , "checking return value -- 7");
       
   187     th.check(al.add("end") , "checking return value -- 8");
       
   188     th.check("a".equals(al.get(0))&& null==al.get(6) && "c".equals(al.get(1)) && "u".equals(al.get(2)) , "checking add ... -- 1");
       
   189     th.check("a".equals(al.get(5))&& "end".equals(al.get(7)) && "n".equals(al.get(3)) && "i".equals(al.get(4)) , "checking add ... -- 2");
       
   190 
       
   191   }
       
   192 /**
       
   193 * implemented. <br>
       
   194 *
       
   195 */
       
   196   public void test_addAll(){
       
   197     th.checkPoint("addAll(java.util.Collection)boolean");
       
   198     ArrayList al =new ArrayList();
       
   199     try { al.addAll(null);
       
   200           th.fail("should throw NullPointerException");
       
   201         }
       
   202     catch (NullPointerException ne) { th.check(true); }
       
   203     Collection c = (Collection) al;
       
   204     th.check(!al.addAll(c) ,"checking returnvalue -- 1");
       
   205     al.add("a"); al.add("b"); al.add("c");
       
   206     c = (Collection) al;
       
   207     al = buildAL();
       
   208     th.check(al.addAll(c) ,"checking returnvalue -- 2");
       
   209     th.check(al.containsAll(c), "extra on containsAll -- 1");
       
   210     th.check(al.get(14)=="a" && al.get(15)=="b" && al.get(16)=="c", "checking added on right positions");
       
   211 
       
   212     th.checkPoint("addAll(int,java.util.Collection)boolean");
       
   213     al =new ArrayList();
       
   214     c = (Collection) al;
       
   215     th.check(!al.addAll(0,c) ,"checking returnvalue -- 1");
       
   216     al.add("a"); al.add("b"); al.add("c");
       
   217     c = (Collection) al;
       
   218     al = buildAL();
       
   219     try { al.addAll(-1,c);
       
   220           th.fail("should throw exception -- 1");
       
   221         }
       
   222     catch (IndexOutOfBoundsException ae) { th.check(true); }
       
   223     try { al.addAll(15,c);
       
   224           th.fail("should throw exception -- 2");
       
   225         }
       
   226     catch (IndexOutOfBoundsException ae) { th.check(true); }
       
   227     try { th.check(al.addAll(11,c),"checking returnvalue -- 2"); }
       
   228     catch (ArrayIndexOutOfBoundsException ae) { th.fail("shouldn't throw exception -- 1"); }
       
   229     th.check(al.containsAll(c), "extra on containsAll -- 1");
       
   230     th.check(al.get(11)=="a" && al.get(12)=="b" && al.get(13)=="c", "checking added on right positions -- 1");
       
   231     th.check(al.addAll(1,c),"checking returnvalue -- 3");
       
   232     th.check(al.get(1)=="a" && al.get(2)=="b" && al.get(3)=="c", "checking added on right positions -- 2");
       
   233 
       
   234   }
       
   235 /**
       
   236 * implemented. <br>
       
   237 *
       
   238 */
       
   239   public void test_clear(){
       
   240     th.checkPoint("clear()void");
       
   241     ArrayList al = new ArrayList();
       
   242     al.clear();
       
   243     al = buildAL();
       
   244     al.clear();
       
   245     th.check(al.size()== 0 && al.isEmpty() , "list is empty ...");
       
   246 
       
   247 
       
   248   }
       
   249 /**
       
   250 * implemented. <br>
       
   251 *
       
   252 */
       
   253   public void test_remove(){
       
   254     th.checkPoint("remove(int)java.lang.Object");
       
   255     ArrayList al = buildAL();
       
   256     try {
       
   257     	al.remove(-1);
       
   258 	th.fail("should throw an IndexOutOfBoundsException -- 1" );
       
   259         }
       
   260     catch (IndexOutOfBoundsException e) { th.check(true); }
       
   261     try {
       
   262     	al.remove(14);
       
   263 	th.fail("should throw an IndexOutOfBoundsException -- 2" );
       
   264         }
       
   265     catch (IndexOutOfBoundsException e) { th.check(true); }
       
   266     th.check( "a".equals(al.remove(5)) , "checking returnvalue remove -- 1");
       
   267     th.check("a".equals(al.get(0))&& null==al.get(5) && "c".equals(al.get(1)) && "u".equals(al.get(2)) , "checking remove ... -- 1");
       
   268     th.check("a".equals(al.get(6))&& "c".equals(al.get(7)) && "n".equals(al.get(3)) && "i".equals(al.get(4)) , "checking remove ... -- 2");
       
   269     th.check(al.size() == 13 , "checking new size -- 1");   	
       
   270     th.check( al.remove(5) == null , "checking returnvalue remove -- 2");
       
   271     th.check(al.size() == 12 , "checking new size -- 2");   	
       
   272     th.check( al.remove(11) == null, "checking returnvalue remove -- 3");
       
   273     th.check( "a".equals(al.remove(0)) , "checking returnvalue remove -- 4");
       
   274     th.check( "u".equals(al.remove(1)) , "checking returnvalue remove -- 5");
       
   275     th.check( "i".equals(al.remove(2)) , "checking returnvalue remove -- 6");
       
   276     th.check( "a".equals(al.remove(2)) , "checking returnvalue remove -- 7");
       
   277     th.check( "u".equals(al.remove(3)) , "checking returnvalue remove -- 8");
       
   278     th.check( "a".equals(al.remove(5)) , "checking returnvalue remove -- 9");
       
   279     th.check( "i".equals(al.remove(4)) , "checking returnvalue remove -- 10");
       
   280     th.check( "c".equals(al.get(0))&& "c".equals(al.get(2)) && "n".equals(al.get(3)) && "n".equals(al.get(1)) , "checking remove ... -- 3");
       
   281     th.check(al.size() == 4 , "checking new size -- 3");   	
       
   282     al.remove(0);
       
   283     al.remove(0);
       
   284     al.remove(0);
       
   285     al.remove(0);
       
   286     th.check(al.size() == 0 , "checking new size -- 4");   	
       
   287 
       
   288     al = new ArrayList();
       
   289     try {
       
   290     	al.remove(0);
       
   291 	th.fail("should throw an IndexOutOfBoundsException -- 3" );
       
   292         }
       
   293     catch (IndexOutOfBoundsException e) { th.check(true); }
       
   294 
       
   295 
       
   296   }
       
   297 /**
       
   298 * implemented. <br>
       
   299 *
       
   300 */
       
   301   public void test_set(){
       
   302     th.checkPoint("set(int,java.lang.Object)java.lang.Object");
       
   303     ArrayList al = new ArrayList();
       
   304     try {
       
   305     	al.set(-1,"a");
       
   306 	th.fail("should throw an IndexOutOfBoundsException -- 1" );
       
   307         }
       
   308     catch (IndexOutOfBoundsException e) { th.check(true); }
       
   309     try {
       
   310     	al.set(0,"a");
       
   311 	th.fail("should throw an IndexOutOfBoundsException -- 2" );
       
   312         }
       
   313     catch (IndexOutOfBoundsException e) { th.check(true); }
       
   314     al = buildAL();
       
   315     try {
       
   316     	al.set(-1,"a");
       
   317 	th.fail("should throw an IndexOutOfBoundsException -- 3" );
       
   318         }
       
   319     catch (IndexOutOfBoundsException e) { th.check(true); }
       
   320     try {
       
   321     	al.set(14,"a");
       
   322 	th.fail("should throw an IndexOutOfBoundsException -- 4" );
       
   323         }
       
   324     catch (IndexOutOfBoundsException e) { th.check(true); }
       
   325     th.check( "a".equals(al.set(5,"b")) , "checking returnvalue of set -- 1");
       
   326     th.check( "a".equals(al.set(0,null)), "checking returnvalue of set -- 2");
       
   327     th.check( "b".equals(al.get(5)), "checking effect of set -- 1");
       
   328     th.check( al.get(0) == null    , "checking effect of set -- 2");
       
   329     th.check( "b".equals(al.set(5,"a")), "checking returnvalue of set -- 3");
       
   330     th.check( al.set(0,null) == null   , "checking returnvalue of set -- 4");
       
   331     th.check( "a".equals(al.get(5)), "checking effect of set -- 3");
       
   332     th.check( al.get(0) == null    , "checking effect of set -- 4");
       
   333 
       
   334   }
       
   335 /**
       
   336 * implemented. <br>
       
   337 *
       
   338 */
       
   339   public void test_contains(){
       
   340     th.checkPoint("contains(java.lang.Object)boolean");
       
   341     ArrayList al = new ArrayList();
       
   342     th.check(!al.contains(null),"checking empty List -- 1");
       
   343     th.check(!al.contains(al)  ,"checking empty List -- 2");
       
   344     al = buildAL();
       
   345     th.check( al.contains(null), "check contains ... -- 1");
       
   346     th.check( al.contains("a") , "check contains ... -- 2");
       
   347     th.check( al.contains("c") , "check contains ... -- 3");
       
   348     th.check(!al.contains(this), "check contains ... -- 4");
       
   349     al.remove(6);
       
   350     th.check( al.contains(null), "check contains ... -- 5");
       
   351     al.remove(12);
       
   352     th.check(!al.contains(null), "check contains ... -- 6");
       
   353     th.check(!al.contains("b") , "check contains ... -- 7");
       
   354     th.check(!al.contains(al)  , "check contains ... -- 8");
       
   355   }
       
   356 /**
       
   357 * implemented. <br>
       
   358 *
       
   359 */
       
   360   public void test_isEmpty(){
       
   361     th.checkPoint("isEmpty()boolean");
       
   362     ArrayList al = new ArrayList();
       
   363     th.check(al.isEmpty() , "checking returnvalue -- 1");
       
   364     al.add("A");
       
   365     th.check(!al.isEmpty() , "checking returnvalue -- 2");
       
   366     al.remove(0);
       
   367     th.check(al.isEmpty() , "checking returnvalue -- 3");
       
   368   }
       
   369 /**
       
   370 * implemented. <br>
       
   371 *
       
   372 */
       
   373   public void test_indexOf(){
       
   374     th.checkPoint("indexOf(java.lang.Object)int");
       
   375     ArrayList al = new ArrayList();
       
   376     th.check( al.indexOf(null)== -1,"checks on empty list -- 1");
       
   377     th.check( al.indexOf(al)== -1 , "checks on empty list -- 2");
       
   378     Object o = new Object();
       
   379     al =buildAL();
       
   380     th.check( al.indexOf(o) == -1 , " doesn't contain -- 1");
       
   381     th.check( al.indexOf("a") == 0 , "contains -- 2");
       
   382     th.check( al.indexOf(o) == -1, "contains -- 3");
       
   383     al.add(9,o);
       
   384     th.check( al.indexOf(o) == 9 , "contains -- 4");
       
   385     th.check( al.indexOf(new Object()) == -1 , "doesn't contain -- 5");
       
   386     th.check(al.indexOf(null) == 6, "null was added to the Vector");
       
   387     al.remove(6);
       
   388     th.check(al.indexOf(null) == 13, "null was added twice to the Vector");
       
   389     al.remove(13);
       
   390     th.check(al.indexOf(null) == -1, "null was removed to the Vector");
       
   391     th.check( al.indexOf("c") == 1 , "contains -- 6");
       
   392     th.check( al.indexOf("u") == 2 , "contains -- 7");
       
   393     th.check( al.indexOf("n") == 3 , "contains -- 8");
       
   394     	
       
   395   }
       
   396 /**
       
   397 * implemented. <br>
       
   398 *
       
   399 */
       
   400   public void test_size(){
       
   401     th.checkPoint("size()int");
       
   402     ArrayList al = new ArrayList();
       
   403     th.check( al.size() == 0 , "check on size -- 1");
       
   404     al.addAll(buildAL());
       
   405     th.check( al.size() == 14 , "check on size -- 1");
       
   406     al.remove(5);
       
   407     th.check( al.size() == 13 , "check on size -- 1");
       
   408     al.add(4,"G");
       
   409     th.check( al.size() == 14 , "check on size -- 1");
       
   410 
       
   411   }
       
   412 /**
       
   413 * implemented. <br>
       
   414 *
       
   415 */
       
   416   public void test_lastIndexOf(){
       
   417     th.checkPoint("lastIndexOf(java.lang.Object)int");
       
   418     ArrayList al = new ArrayList();
       
   419     th.check( al.lastIndexOf(null)== -1,"checks on empty list -- 1");
       
   420     th.check( al.lastIndexOf(al)== -1 , "checks on empty list -- 2");
       
   421     Object o = new Object();
       
   422     al =buildAL();
       
   423     th.check( al.lastIndexOf(o) == -1 , " doesn't contain -- 1");
       
   424     th.check( al.lastIndexOf("a") == 12 , "contains -- 2");
       
   425     th.check( al.lastIndexOf(o) == -1, "contains -- 3");
       
   426     al.add(9,o);
       
   427     th.check( al.lastIndexOf(o) == 9 , "contains -- 4");
       
   428     th.check( al.lastIndexOf(new Object()) == -1 , "doesn't contain -- 5");
       
   429     th.check( al.lastIndexOf(null) == 14, "null was added to the Vector");
       
   430     al.remove(14);
       
   431     th.check( al.lastIndexOf(null) == 6 , "null was added twice to the Vector");
       
   432     al.remove(6);
       
   433     th.check( al.lastIndexOf(null) == -1, "null was removed to the Vector");
       
   434     th.check( al.lastIndexOf("c") == 7 , "contains -- 6, got "+al.lastIndexOf("c"));
       
   435     th.check( al.lastIndexOf("u") == 9 , "contains -- 7, got "+al.lastIndexOf("u"));
       
   436     th.check( al.lastIndexOf("n") == 10, "contains -- 8, got "+al.lastIndexOf("n"));
       
   437 
       
   438   }
       
   439 /**
       
   440 * implemented. <br>
       
   441 *
       
   442 */
       
   443   public void test_toArray(){
       
   444    th.checkPoint("toArray()[java.lang.Object");
       
   445     ArrayList v = new ArrayList();
       
   446     Object o[] = v.toArray();
       
   447     th.check(o.length == 0 , "checking size Object array");
       
   448     v.add("a"); v.add(null); v.add("b");
       
   449     o = v.toArray();
       
   450     th.check(o[0]== "a" && o[1] == null && o[2] == "b" , "checking elements -- 1");
       
   451     th.check(o.length == 3 , "checking size Object array");
       
   452 
       
   453   th.checkPoint("toArray([java.lang.Object)[java.lang.Object");
       
   454     v = new ArrayList();
       
   455     try { v.toArray(null);
       
   456           th.fail("should throw NullPointerException -- 1");
       
   457         }
       
   458     catch (NullPointerException ne) { th.check(true); }
       
   459     v.add("a"); v.add(null); v.add("b");
       
   460     String sa[] = new String[5];
       
   461     sa[3] = "deleteme"; sa[4] = "leavemealone";
       
   462     th.check(v.toArray(sa) == sa , "sa is large enough, no new array created");
       
   463     th.check(sa[0]=="a" && sa[1] == null && sa[2] == "b" , "checking elements -- 1"+sa[0]+", "+sa[1]+", "+sa[2]);
       
   464     th.check(sa.length == 5 , "checking size Object array");
       
   465     th.check(sa[3]==null && sa[4]=="leavemealone", "check other elements -- 1"+sa[3]+", "+sa[4]);
       
   466     v = buildAL();
       
   467     try { v.toArray(null);
       
   468           th.fail("should throw NullPointerException -- 2");
       
   469         }
       
   470     catch (NullPointerException ne) { th.check(true); }
       
   471     try { v.toArray(new Class[5]);
       
   472           th.fail("should throw an ArrayStoreException");
       
   473         }
       
   474     catch (ArrayStoreException ae) { th.check(true); }
       
   475     v.add(null);
       
   476     String sar[];
       
   477     sa = new String[15];
       
   478     sar = (String[])v.toArray(sa);
       
   479     th.check( sar == sa , "returned array is the same");
       
   480 
       
   481   }
       
   482 /**
       
   483 * implemented. <br>
       
   484 *
       
   485 */
       
   486   public void test_clone(){
       
   487     th.checkPoint("clone()java.lang.Object");
       
   488     ArrayList cal,al = new ArrayList();
       
   489     cal = (ArrayList)al.clone();
       
   490     th.check(cal.size() == 0, "checking size -- 1");
       
   491     al.add("a")	;al.add("b")    ;al.add("c"); al.add(null);
       
   492     cal = (ArrayList)al.clone();
       
   493     th.check(cal.size() == al.size(), "checking size -- 2");
       
   494     th.check( al != cal , "Objects are not the same");
       
   495     th.check( al.equals(cal) , "cloned list is equal");
       
   496     al.add("a");
       
   497     th.check(cal.size() == 4, "changes in one object doen't affect the other -- 2");
       
   498 
       
   499   }
       
   500 
       
   501 /**
       
   502 * implemented. <br>
       
   503 *
       
   504 */
       
   505   public void test_removeRange(){
       
   506     th.checkPoint("removeRange(int,int)void");
       
   507     AcuniaArrayListTest xal = new AcuniaArrayListTest(buildAL());
       
   508     ArrayList al = buildAL();
       
   509     xal.ensureCapacity(40);
       
   510     try {
       
   511     	xal.removeRange(0,-1);
       
   512         th.fail("should throw an IndexOutOfBoundsException -- 1");
       
   513         }
       
   514     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   515     th.check(xal.equals(al) , "ArrayList must not be changed -- 1");
       
   516 
       
   517     try {
       
   518     	xal.removeRange(-1,2);
       
   519         th.fail("should throw an IndexOutOfBoundsException -- 2");
       
   520         }
       
   521     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   522     th.check(xal.equals(al) , "ArrayList must not be changed -- 2");
       
   523     try {
       
   524     	xal.removeRange(3,2);
       
   525         th.fail("should throw an IndexOutOfBoundsException -- 3");
       
   526         }
       
   527     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   528     try {
       
   529     	th.check(al.equals(xal) , "ArrayList must not be changed -- 3");
       
   530     }
       
   531     catch (Exception e) { th.debug("bad operations messed up ArrayList"); }
       
   532     xal = new AcuniaArrayListTest(buildAL());
       
   533     xal.ensureCapacity(40);
       
   534     try {
       
   535     	xal.removeRange(3,15);
       
   536         th.fail("should throw an IndexOutOfBoundsException -- 4");
       
   537         }
       
   538     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   539     th.check(xal.equals(al) , "ArrayList must not be changed -- 4");
       
   540     xal = new AcuniaArrayListTest(buildAL());
       
   541     xal.ensureCapacity(40);
       
   542     try {
       
   543     	xal.removeRange(15,13);
       
   544         th.fail("should throw an IndexOutOfBoundsException -- 5");
       
   545         }
       
   546     catch(IndexOutOfBoundsException ioobe) { th.check(true); }
       
   547     try {
       
   548     	th.check(xal.equals(al) , "ArrayList must not be changed -- 5");
       
   549     }
       
   550     catch (Exception e) { th.debug("bad operations messed up ArrayList"); }
       
   551     xal = new AcuniaArrayListTest(buildAL());
       
   552     xal.ensureCapacity(40);
       
   553     xal.removeRange(14,14);
       
   554     th.check(xal.size() == 14 , "no elements should have been removed -- 6, size = "+xal.size());
       
   555     xal.removeRange(10,14);
       
   556     th.check(xal.size() == 10 , "4 elements should have been removed");
       
   557     th.check( "a".equals(xal.get(0)) && "a".equals(xal.get(5)) && "a".equals(xal.get(7)) ,"check contents -- 1");
       
   558     xal.removeRange(2,7);
       
   559     th.check(xal.size() == 5 , "5 elements should have been removed");
       
   560     th.check( "a".equals(xal.get(0)) && "c".equals(xal.get(1)) && "a".equals(xal.get(2))
       
   561                  && "c".equals(xal.get(3)) && "u".equals(xal.get(4)) ,"check contents -- 2");
       
   562     xal.removeRange(0,2);
       
   563     th.check( "a".equals(xal.get(0)) && "c".equals(xal.get(1)) && "u".equals(xal.get(2)) ,"check contents -- 3");
       
   564     th.check(xal.size() == 3 , "2 elements should have been removed");
       
   565   }
       
   566 
       
   567 /**
       
   568 * implemented. <br>
       
   569 *
       
   570 */
       
   571   public void test_MC_iterator(){
       
   572     th.checkPoint("ModCount(in)iterator");
       
   573     AcuniaArrayListTest xal = new AcuniaArrayListTest(buildAL());
       
   574     Iterator it = xal.iterator();
       
   575     xal.removeRange(1,10);
       
   576     try {
       
   577     	it.next();
       
   578         th.fail("should throw a ConcurrentModificationException -- 1");
       
   579         }
       
   580     catch(ConcurrentModificationException ioobe) { th.check(true); }
       
   581     ArrayList al = buildAL();
       
   582     it = al.iterator();
       
   583     al.trimToSize();
       
   584     try {
       
   585     	it.next();
       
   586         th.fail("should throw a ConcurrentModificationException -- 3");
       
   587     } catch(ConcurrentModificationException ioobe) { th.check(true); }
       
   588 
       
   589     it = al.iterator();
       
   590     al.ensureCapacity(25);
       
   591     try {
       
   592     	it.next();
       
   593         th.fail("should throw a ConcurrentModificationException -- 3");
       
   594     } catch(ConcurrentModificationException ioobe) { th.check(true); }
       
   595 
       
   596     it = al.iterator();
       
   597     al.get(0);
       
   598     al.contains(null);
       
   599     al.isEmpty();
       
   600     al.indexOf(null);
       
   601     al.lastIndexOf(null);
       
   602     al.size();
       
   603     al.toArray();
       
   604     al.toArray(new String[10]);
       
   605     al.clone();
       
   606     try {
       
   607     	it.next();
       
   608     	th.check(true);
       
   609         }
       
   610     catch(ConcurrentModificationException ioobe) { th.fail("should not throw a ConcurrentModificationException -- 2"); }
       
   611 
       
   612     it = al.iterator();
       
   613     al.add("b");
       
   614     try {
       
   615     	it.next();
       
   616         th.fail("should throw a ConcurrentModificationException -- 3");
       
   617         }
       
   618     catch(ConcurrentModificationException ioobe) { th.check(true); }
       
   619 
       
   620     it = al.iterator();
       
   621     al.add(3,"b");
       
   622     try {
       
   623     	it.next();
       
   624         th.fail("should throw a ConcurrentModificationException -- 4");
       
   625         }
       
   626     catch(ConcurrentModificationException ioobe) { th.check(true); }
       
   627 
       
   628     it = al.iterator();
       
   629     al.addAll(xal);
       
   630     try {
       
   631     	it.next();
       
   632         th.fail("should throw a ConcurrentModificationException -- 5");
       
   633         }
       
   634     catch(ConcurrentModificationException ioobe) { th.check(true); }
       
   635 
       
   636     it = al.iterator();
       
   637     al.addAll(2,xal);
       
   638     try {
       
   639     	it.next();
       
   640         th.fail("should throw a ConcurrentModificationException -- 6");
       
   641         }
       
   642     catch(ConcurrentModificationException ioobe) { th.check(true); }
       
   643 
       
   644     it = al.iterator();
       
   645     al.remove(2);
       
   646     try {
       
   647     	it.next();
       
   648         th.fail("should throw a ConcurrentModificationException -- 8");
       
   649         }
       
   650     catch(ConcurrentModificationException ioobe) { th.check(true); }
       
   651 
       
   652     it = al.iterator();
       
   653     al.clear();
       
   654     try {
       
   655     	it.next();
       
   656         th.fail("should throw a ConcurrentModificationException -- 9");
       
   657         }
       
   658     catch(ConcurrentModificationException ioobe) { th.check(true); }
       
   659   }
       
   660 
       
   661 // The following fields and methods are used in tests that need an ArrayList.
       
   662 
       
   663         private boolean didRemoveRange=false;
       
   664         private int from = -1;
       
   665         private int to   = -1;
       
   666         public AcuniaArrayListTest(Collection c){
       
   667                 super(c);
       
   668         }
       
   669 
       
   670         public void removeRange(int fidx, int tidx) {
       
   671                 didRemoveRange=true;
       
   672                 to   = tidx;
       
   673                 from = fidx;
       
   674                 super.removeRange(fidx, tidx);
       
   675         }
       
   676 
       
   677         public boolean get_dRR() {
       
   678                 return didRemoveRange;
       
   679         }
       
   680         public void set_dRR(boolean b) {
       
   681                 didRemoveRange = b;
       
   682         }
       
   683         public int get_to() {
       
   684                 return to;
       
   685         }
       
   686         public int get_from() {
       
   687                 return from;
       
   688         }
       
   689 
       
   690 }