harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r599829 [3/3] - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/TreeMap.java test/api/common/tests/api/java/util/TreeMapTest.java
Date Fri, 30 Nov 2007 14:22:38 GMT
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/TreeMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/TreeMapTest.java?rev=599829&r1=599828&r2=599829&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/TreeMapTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/TreeMapTest.java
Fri Nov 30 06:22:23 2007
@@ -74,6 +74,9 @@
             if (null == o1) {
                 return -1;
             }
+            if (null == o2) { // comparator should be symmetric
+                return 1;
+            }
             return o1.compareTo(o2);
         }
     }
@@ -327,6 +330,48 @@
         treemap = new TreeMap();
 		SortedMap<String, String> headMap =  treemap.headMap("100");
 		headMap.headMap("100");
+
+	SortedMap<Integer,Integer> intMap,sub;
+        int size = 16;
+        intMap = new TreeMap<Integer,Integer>();
+        for(int i=0; i<size; i++) {
+            intMap.put(i,i);
+        }
+        sub = intMap.headMap(-1);
+        assertEquals("size should be zero",sub.size(),0);
+        assertTrue("submap should be empty",sub.isEmpty());
+        try{
+            sub.firstKey();
+            fail("java.util.NoSuchElementException should be thrown");
+        } catch(java.util.NoSuchElementException e) {
+        }
+        
+        try{
+            sub.lastKey();
+            fail("java.util.NoSuchElementException should be thrown");
+        } catch(java.util.NoSuchElementException e) {
+        }
+
+        size = 256;
+        intMap = new TreeMap<Integer,Integer>();
+        for(int i=0; i<size; i++) {
+            intMap.put(i,i);
+        }
+        sub = intMap.headMap(-1);
+        assertEquals("size should be zero",sub.size(),0);
+        assertTrue("submap should be empty",sub.isEmpty());
+        try{
+            sub.firstKey();
+            fail("java.util.NoSuchElementException should be thrown");
+        } catch(java.util.NoSuchElementException e) {
+        }
+        
+        try{
+            sub.lastKey();
+            fail("java.util.NoSuchElementException should be thrown");
+        } catch(java.util.NoSuchElementException e) {
+        }
+
     }
 
     /**
@@ -469,6 +514,48 @@
 
         // Regression for Harmony-1066
         assertTrue(tail instanceof Serializable);
+
+	SortedMap<Integer,Integer> intMap,sub;
+        int size = 16;
+        intMap = new TreeMap<Integer,Integer>();
+        for(int i=0; i<size; i++) {
+            intMap.put(i,i);
+        }
+        sub = intMap.tailMap(size);
+        assertEquals("size should be zero",sub.size(),0);
+        assertTrue("submap should be empty",sub.isEmpty());
+        try{
+            sub.firstKey();
+            fail("java.util.NoSuchElementException should be thrown");
+        } catch(java.util.NoSuchElementException e) {
+        }
+        
+        try{
+            sub.lastKey();
+            fail("java.util.NoSuchElementException should be thrown");
+        } catch(java.util.NoSuchElementException e) {
+        }
+
+        size = 256;
+        intMap = new TreeMap<Integer,Integer>();
+        for(int i=0; i<size; i++) {
+            intMap.put(i,i);
+        }
+        sub = intMap.tailMap(size);
+        assertEquals("size should be zero",sub.size(),0);
+        assertTrue("submap should be empty",sub.isEmpty());
+        try{
+            sub.firstKey();
+            fail("java.util.NoSuchElementException should be thrown");
+        } catch(java.util.NoSuchElementException e) {
+        }
+        
+        try{
+            sub.lastKey();
+            fail("java.util.NoSuchElementException should be thrown");
+        } catch(java.util.NoSuchElementException e) {
+        }
+
     }
 
     /**



Mime
View raw message