harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qi...@apache.org
Subject svn commit: r798787 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java
Date Wed, 29 Jul 2009 05:54:42 GMT
Author: qiuxx
Date: Wed Jul 29 05:54:41 2009
New Revision: 798787

URL: http://svn.apache.org/viewvc?rev=798787&view=rev
Log:
Add testcase to test TreeMap.subMap's iterator

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java?rev=798787&r1=798786&r2=798787&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java
Wed Jul 29 05:54:41 2009
@@ -497,6 +497,48 @@
         SortedMap<String, String> sub = map.subMap("1", "3"); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals("2", sub.lastKey()); //$NON-NLS-1$
     }
+    
+    
+    /**
+     * @tests java.util.TreeMap#subMap(java.lang.Object, java.lang.Object)
+     */
+    public void test_subMap_Iterator() {
+        TreeMap<String, String> map = new TreeMap<String, String>();
+
+        String[] keys = { "1", "2", "3" };
+        String[] values = { "one", "two", "three" };
+        for (int i = 0; i < keys.length; i++) {
+            map.put(keys[i], values[i]);
+        }
+
+        assertEquals(3, map.size());
+
+        Map subMap = map.subMap("", "test");
+        assertEquals(3, subMap.size());
+
+        Set entrySet = subMap.entrySet();
+        Iterator iter = entrySet.iterator();
+        int size = 0;
+        while (iter.hasNext()) {
+            Map.Entry<String, String> entry = (Map.Entry<String, String>) iter
+                    .next();
+            assertTrue(map.containsKey(entry.getKey()));
+            assertTrue(map.containsValue(entry.getValue()));
+            size++;
+        }
+        assertEquals(map.size(), size);
+
+        Set<String> keySet = subMap.keySet();
+        iter = keySet.iterator();
+        size = 0;
+        while (iter.hasNext()) {
+            String key = (String) iter.next();
+            assertTrue(map.containsKey(key));
+            size++;
+        }
+        assertEquals(map.size(), size);
+    }
+
 
     /**
      * @tests java.util.TreeMap#tailMap(java.lang.Object)



Mime
View raw message