commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections AbstractTestCollection.java
Date Sun, 19 Oct 2003 00:25:11 GMT
scolebourne    2003/10/18 17:25:11

  Modified:    collections/src/test/org/apache/commons/collections
                        AbstractTestCollection.java
  Log:
  Better test error messages
  Handle small test collections
  
  Revision  Changes    Path
  1.6       +25 -16    jakarta-commons/collections/src/test/org/apache/commons/collections/AbstractTestCollection.java
  
  Index: AbstractTestCollection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/AbstractTestCollection.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractTestCollection.java	10 Oct 2003 21:19:39 -0000	1.5
  +++ AbstractTestCollection.java	19 Oct 2003 00:25:11 -0000	1.6
  @@ -321,7 +321,7 @@
               // no match found!
               if(!match) {
                   fail("Collection should not contain a value that the " +
  -                     "confirmed collection does not have.");
  +                     "confirmed collection does not have: " + o);
               }
           }
           
  @@ -727,12 +727,14 @@
           // make sure calls to "containsAll" don't change anything
           verify();
   
  -        col = Arrays.asList(getFullElements()).subList(2, 5);
  +        int min = (getFullElements().length < 2 ? 0 : 2);
  +        int max = (getFullElements().length == 1 ? 1 : 
  +                    (getFullElements().length <= 5 ? getFullElements().length - 1 :
5));
  +        col = Arrays.asList(getFullElements()).subList(min, max);
           assertTrue("Full collection should containAll partial full " +
                      "elements", collection.containsAll(col));
           assertTrue("Full collection should containAll itself", 
                      collection.containsAll(collection));
  -
           // make sure calls to "containsAll" don't change anything
           verify();
           
  @@ -959,7 +961,10 @@
           
           resetFull();
           int size = collection.size();
  -        Collection all = Arrays.asList(getFullElements()).subList(2, 5);
  +        int min = (getFullElements().length < 2 ? 0 : 2);
  +        int max = (getFullElements().length == 1 ? 1 : 
  +                    (getFullElements().length <= 5 ? getFullElements().length - 1 :
5));
  +        Collection all = Arrays.asList(getFullElements()).subList(min, max);
           assertTrue("Full collection removeAll should work", 
                      collection.removeAll(all));
           confirmed.removeAll(all);
  @@ -1013,17 +1018,21 @@
           assertEquals("Collection size shouldn't change", size, 
                        collection.size());
           
  -        resetFull();
  -        size = collection.size();
  -        assertTrue("Collection should changed by partial retainAll",
  -                   collection.retainAll(elements.subList(2, 5)));
  -        confirmed.retainAll(elements.subList(2, 5));
  -        verify();
  +        if (getFullElements().length > 1) {
  +            resetFull();
  +            size = collection.size();
  +            int min = (getFullElements().length < 2 ? 0 : 2);
  +            int max = (getFullElements().length <= 5 ? getFullElements().length - 1
: 5);
  +            assertTrue("Collection should changed by partial retainAll",
  +                       collection.retainAll(elements.subList(min, max)));
  +            confirmed.retainAll(elements.subList(min, max));
  +            verify();
           
  -        Iterator iter = collection.iterator();
  -        while (iter.hasNext()) {
  -            assertTrue("Collection only contains retained element", 
  -                       elements.subList(2, 5).contains(iter.next()));
  +            Iterator iter = collection.iterator();
  +            while (iter.hasNext()) {
  +                assertTrue("Collection only contains retained element", 
  +                           elements.subList(min, max).contains(iter.next()));
  +            }
           }
           
           resetFull();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message