You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2002/11/24 21:49:29 UTC

cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestSequencedHashMap.java

scolebourne    2002/11/24 12:49:29

  Modified:    collections/src/test/org/apache/commons/collections
                        TestSequencedHashMap.java
  Log:
  Test for indexOf, from Johal
  
  Revision  Changes    Path
  1.17      +17 -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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TestSequencedHashMap.java	1 Nov 2002 19:07:53 -0000	1.16
  +++ TestSequencedHashMap.java	24 Nov 2002 20:49:29 -0000	1.17
  @@ -93,7 +93,7 @@
           return 2;
       }
   
  -    public static void main(String[] args[]) {
  +    public static void main(String[] args) {
           String[] testCaseName = { TestSequencedHashMap.class.getName() };
           junit.textui.TestRunner.main(testCaseName);
       }
  @@ -206,6 +206,22 @@
                        map2.getLastKey(),getSampleKeys()[getSampleKeys().length - 1]);
       }
   
  +    public void testIndexOf() throws Exception {
  +        Object[] keys = getKeys();
  +        int expectedSize = keys.length;
  +        Object[] values = getValues();
  +        for (int i = 0; i < expectedSize; i++) {
  +            labRat.put(keys[i], values[i]);
  +        }
  +        // test that the index returned are in the same order that they were 
  +        // placed in the map
  +        for (int i = 0; i < keys.length; i++) {
  +            assertEquals("indexOf with existing key failed", i, labRat.indexOf(keys[i]));
  +        }
  +        // test non existing key..
  +        assertEquals("test with non-existing key failed", -1, labRat.indexOf("NonExistingKey"));
  +    }
  +    
       protected void tearDown() throws Exception {
           labRat = null;
       }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>