Code example for IdentityHashMap

Methods: get, put

0
 
    /** 
     * @tests java.util.IdentityHashMap#put(java.lang.Object, java.lang.Object) 
     */ 
    public void test_putLjava_lang_ObjectLjava_lang_Object() { 
        IdentityHashMap<Object, Object> map = new IdentityHashMap<Object, Object>();
 
        // Test null as a key. 
        Object value = "Some value";
        map.put(null, value);
        assertSame("Assert 0: Failure getting null key", value, map.get(null));
 
        // Test null as a value 
        Object key = "Some key";
        map.put(key, null);
        assertNull("Assert 1: Failure getting null value", map.get(key));
    } 
 
	/** 
	 * @tests java.util.IdentityHashMap#remove(java.lang.Object) 
	 * @tests java.util.IdentityHashMap#keySet()