Code example for TreeMap

Methods: ceilingEntry, ceilingKey, comparator, containsKey, containsValue, firstEntry, firstKey, floorEntry, floorKey, higherEntry

0
    SortedMap subMap_startIncluded_endIncluded_comparator;
 
    Object objArray[] = new Object[1000];
 
    public void test_TreeMap_Constructor_Default() { 
        TreeMap treeMap = new TreeMap();
        assertTrue(treeMap.isEmpty());
        assertNull(treeMap.comparator());
        assertEquals(0, treeMap.size());
 
        try { 
            treeMap.firstKey();
            fail("should throw NoSuchElementException");
        } catch (NoSuchElementException e) {
            // Expected 
        } 
        assertNull(treeMap.firstEntry());
 
        try { 
            treeMap.lastKey();
            fail("should throw NoSuchElementException");
        } catch (NoSuchElementException e) {
            // Expected 
        } 
        assertNull(treeMap.lastEntry());
 
        try { 
            treeMap.ceilingKey(1);
        } catch (NoSuchElementException e) {
            // Expected 
        } 
        assertNull(treeMap.ceilingEntry(1));
 
        try { 
            treeMap.floorKey(1);
        } catch (NoSuchElementException e) {
            // Expected 
        } 
        assertNull(treeMap.floorEntry(1));
        assertNull(treeMap.lowerKey(1));
        assertNull(treeMap.lowerEntry(1));
        assertNull(treeMap.higherKey(1));
        assertNull(treeMap.higherEntry(1));
        assertFalse(treeMap.containsKey(1));
        assertFalse(treeMap.containsValue(1));
        assertNull(treeMap.get(1));
 
        assertNull(treeMap.pollFirstEntry());
        assertNull(treeMap.pollLastEntry());
        assertEquals(0, treeMap.values().size());