Search in sources :

Example 6 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_ConstructorIF.

/**
     * java.util.WeakHashMap#WeakHashMap(int, float)
     */
public void test_ConstructorIF() {
    // Test for method java.util.WeakHashMap(int, float)
    whm = new WeakHashMap(50, 0.5f);
    for (int i = 0; i < 100; i++) whm.put(keyArray[i], valueArray[i]);
    for (int i = 0; i < 100; i++) assertTrue("Incorrect value retrieved", whm.get(keyArray[i]) == valueArray[i]);
    WeakHashMap empty = new WeakHashMap(0, 0.75f);
    assertNull("Empty hashtable access", empty.get("nothing"));
    empty.put("something", "here");
    assertTrue("cannot get element", empty.get("something") == "here");
    try {
        new WeakHashMap(50, -0.5f);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new WeakHashMap(-50, 0.5f);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
}
Also used : WeakHashMap(java.util.WeakHashMap)

Example 7 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_clear.

/**
     * java.util.WeakHashMap#clear()
     */
public void test_clear() {
    // Test for method boolean java.util.WeakHashMap.clear()
    whm = new WeakHashMap();
    for (int i = 0; i < 100; i++) whm.put(keyArray[i], valueArray[i]);
    whm.clear();
    assertTrue("Cleared map should be empty", whm.isEmpty());
    for (int i = 0; i < 100; i++) assertNull("Cleared map should only return null", whm.get(keyArray[i]));
}
Also used : WeakHashMap(java.util.WeakHashMap)

Example 8 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_ConstructorLjava_util_Map.

/**
     * java.util.WeakHashMap#WeakHashMap(java.util.Map)
     */
public void test_ConstructorLjava_util_Map() {
    Map mockMap = new MockMap();
    WeakHashMap map = new WeakHashMap(mockMap);
    assertEquals("Size should be 0", 0, map.size());
    try {
        new WeakHashMap(null);
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    //expected
    }
}
Also used : AbstractMap(java.util.AbstractMap) Map(java.util.Map) WeakHashMap(java.util.WeakHashMap) WeakHashMap(java.util.WeakHashMap)

Example 9 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_isEmpty.

/**
     * java.util.WeakHashMap#isEmpty()
     */
public void test_isEmpty() {
    // Test for method boolean java.util.WeakHashMap.isEmpty()
    whm = new WeakHashMap();
    assertTrue("New map should be empty", whm.isEmpty());
    Object myObject = new Object();
    whm.put(myObject, myObject);
    assertTrue("Map should not be empty", !whm.isEmpty());
    whm.remove(myObject);
    assertTrue("Map with elements removed should be empty", whm.isEmpty());
}
Also used : WeakHashMap(java.util.WeakHashMap)

Example 10 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_containsKeyLjava_lang_Object.

/**
     * java.util.WeakHashMap#containsKey(java.lang.Object)
     */
public void test_containsKeyLjava_lang_Object() {
    // Test for method boolean java.util.WeakHashMap.containsKey()
    whm = new WeakHashMap();
    for (int i = 0; i < 100; i++) whm.put(keyArray[i], valueArray[i]);
    for (int i = 0; i < 100; i++) assertTrue("Should contain referenced key", whm.containsKey(keyArray[i]));
    keyArray[25] = null;
    keyArray[50] = null;
}
Also used : WeakHashMap(java.util.WeakHashMap)

Aggregations

WeakHashMap (java.util.WeakHashMap)65 Map (java.util.Map)19 HashMap (java.util.HashMap)18 TreeMap (java.util.TreeMap)15 IdentityHashMap (java.util.IdentityHashMap)13 AbstractMap (java.util.AbstractMap)12 LinkedHashMap (java.util.LinkedHashMap)12 ICC_ColorSpace (java.awt.color.ICC_ColorSpace)8 ColorTransform (sun.java2d.cmm.ColorTransform)8 PCMM (sun.java2d.cmm.PCMM)8 Hashtable (java.util.Hashtable)6 AttributedString (java.text.AttributedString)5 Properties (java.util.Properties)5 ArrayList (java.util.ArrayList)4 Comparator (java.util.Comparator)4 List (java.util.List)4 TreeSet (java.util.TreeSet)4 WeakReference (java.lang.ref.WeakReference)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 AttributedCharacterIterator (java.text.AttributedCharacterIterator)3