Code example for TreeMap

Methods: clear, entrySet, isEmpty, keySet, put, remove, size, values

0
    public final void testIsEmpty() { 
        assertEquals(ref.isEmpty(), map.isEmpty());
    } 
     
    public final void testIsEmpty2() { 
        TreeMap<String, String> map = new TreeMap<String, String>();
        map.put("one", "1");
        assertEquals("size should be one", 1, map.size());
        map.clear();
        assertEquals("size should be zero", 0, map.size());
        assertTrue("Should not have entries", !map.entrySet().iterator()
                .hasNext());
 
        map.put("one", "1");
        assertEquals("size should be one", 1, map.size());
        map.remove("one");
        assertEquals("size should be zero", 0, map.size());
        assertTrue("Should not have entries", !map.entrySet().iterator()
                .hasNext());
 
        map.clear();
        map.put("0", "1");
        map.clear();
        assertTrue(map.isEmpty());
        assertFalse(map.entrySet().iterator().hasNext());
        assertFalse(map.keySet().iterator().hasNext());
        assertFalse(map.values().iterator().hasNext());
    } 
     
    public final void testToString() { 
        assertEquals(ref.toString(), map.toString());
    }