commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morg...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestMap.java TestSequencedHashMap.java
Date Thu, 21 Feb 2002 19:57:33 GMT
morgand     02/02/21 11:57:33

  Modified:    collections/src/test/org/apache/commons/collections
                        TestMap.java TestSequencedHashMap.java
  Log:
  unit test to reproduce a SequencedHashMap 1.3 bug
  
  Revision  Changes    Path
  1.5       +34 -5     jakarta-commons/collections/src/test/org/apache/commons/collections/TestMap.java
  
  Index: TestMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMap.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestMap.java	20 Feb 2002 22:38:46 -0000	1.4
  +++ TestMap.java	21 Feb 2002 19:57:33 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMap.java,v
1.4 2002/02/20 22:38:46 morgand Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/02/20 22:38:46 $
  + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMap.java,v
1.5 2002/02/21 19:57:33 morgand Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/02/21 19:57:33 $
    *
    * ====================================================================
    *
  @@ -62,8 +62,9 @@
   package org.apache.commons.collections;
   
   import junit.framework.*;
  -import java.util.Map;
   import java.util.Collection;
  +import java.util.Map;
  +import java.util.Set;
   
   /**
    * Tests base {@link java.util.Map} methods and contracts.
  @@ -76,7 +77,7 @@
    * test case (method) your {@link Map} fails.
    *
    * @author Rodney Waldhoff
  - * @version $Id: TestMap.java,v 1.4 2002/02/20 22:38:46 morgand Exp $
  + * @version $Id: TestMap.java,v 1.5 2002/02/21 19:57:33 morgand Exp $
    */
   public abstract class TestMap extends TestObject {
       public TestMap(String testName) {
  @@ -203,6 +204,30 @@
           assertTrue("size of Map should be 3, but was " + map.size(), map.size() == 3);
       }
   
  +    public void testEntrySetRemove() {
  +
  +        if ((this instanceof TestMap.EntrySetSupportsRemove) == false) {
  +            return;
  +        }
  +
  +        Map map = makeMap();
  +        map.put("1","1");
  +        map.put("2","2");
  +        map.put("3","3");
  +
  +        Object o = map.entrySet().iterator().next();
  +        // remove one of the key/value pairs
  +        Set set = map.entrySet();
  +        set.remove(o);
  +        assertTrue(set.size() == 2);
  +        // try to remove it again, to make sure 
  +        // the Set is not confused by missing entries
  +        set.remove(o);
  +
  +        assertTrue("size of Map should be 2, but was " + map.size(), map.size() == 2);
  +
  +    }
  +
       /*
           // optional operation
   public void testMapClear() {
  @@ -239,6 +264,10 @@
        * can test put(Object,Object) operations.
        */
       public interface SupportsPut {
  +
  +    }
  +
  +    public interface EntrySetSupportsRemove {
   
       }
   
  
  
  
  1.6       +2 -1      jakarta-commons/collections/src/test/org/apache/commons/collections/TestSequencedHashMap.java
  
  Index: TestSequencedHashMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestSequencedHashMap.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestSequencedHashMap.java	20 Feb 2002 22:38:46 -0000	1.5
  +++ TestSequencedHashMap.java	21 Feb 2002 19:57:33 -0000	1.6
  @@ -73,7 +73,8 @@
    * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    */
  -public class TestSequencedHashMap extends TestMap implements TestMap.SupportsPut
  +public class TestSequencedHashMap extends TestMap 
  +implements TestMap.SupportsPut, TestMap.EntrySetSupportsRemove
   {
       /**
        * The instance to experiment on.
  
  
  

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


Mime
View raw message