Search in sources :

Example 46 with IdentityHashMap

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

the class IdentityHashMapTest method test_Constructor.

/**
     * java.util.IdentityHashMap#IdentityHashMap()
     */
public void test_Constructor() {
    // Test for method java.util.IdentityHashMap()
    new Support_MapTest2(new IdentityHashMap()).runTest();
    IdentityHashMap hm2 = new IdentityHashMap();
    assertEquals("Created incorrect IdentityHashMap", 0, hm2.size());
}
Also used : IdentityHashMap(java.util.IdentityHashMap) Support_MapTest2(tests.support.Support_MapTest2)

Example 47 with IdentityHashMap

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

the class IdentityHashMapTest method test_values.

/**
     * java.util.IdentityHashMap#values()
     */
public void test_values() {
    // Test for method java.util.Collection
    // java.util.IdentityHashMap.values()
    Collection c = hm.values();
    assertTrue("Returned collection of incorrect size()", c.size() == hm.size());
    for (int i = 0; i < objArray.length; i++) assertTrue("Returned collection does not contain all keys", c.contains(objArray[i]));
    IdentityHashMap myIdentityHashMap = new IdentityHashMap();
    for (int i = 0; i < 100; i++) myIdentityHashMap.put(objArray2[i], objArray[i]);
    Collection values = myIdentityHashMap.values();
    values.remove(objArray[0]);
    assertTrue("Removing from the values collection should remove from the original map", !myIdentityHashMap.containsValue(objArray2[0]));
}
Also used : IdentityHashMap(java.util.IdentityHashMap) Collection(java.util.Collection)

Example 48 with IdentityHashMap

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

the class IdentityHashMapTest method test_removeLjava_lang_Object.

/**
     * java.util.IdentityHashMap#remove(java.lang.Object)
     */
public void test_removeLjava_lang_Object() {
    // Test for method java.lang.Object
    // java.util.IdentityHashMap.remove(java.lang.Object)
    int size = hm.size();
    Integer x = ((Integer) hm.remove(objArray2[9]));
    assertTrue("Remove returned incorrect value", x.equals(new Integer(9)));
    assertNull("Failed to remove given key", hm.get(objArray2[9]));
    assertTrue("Failed to decrement size", hm.size() == (size - 1));
    assertNull("Remove of non-existent key returned non-null", hm.remove("LCLCLC"));
    IdentityHashMap m = new IdentityHashMap();
    m.put(null, "test");
    assertNull("Failed with same hash as null", m.remove(objArray[0]));
    assertEquals("Failed with null key", "test", m.remove(null));
}
Also used : IdentityHashMap(java.util.IdentityHashMap)

Example 49 with IdentityHashMap

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

the class IdentityHashMapTest method test_containsKeyLjava_lang_Object.

/**
     * java.util.IdentityHashMap#containsKey(java.lang.Object)
     */
public void test_containsKeyLjava_lang_Object() {
    // Test for method boolean
    // java.util.IdentityHashMap.containsKey(java.lang.Object)
    assertTrue("Returned false for valid key", hm.containsKey(objArray2[23]));
    assertTrue("Returned true for copy of valid key", !hm.containsKey(new Integer(23).toString()));
    assertTrue("Returned true for invalid key", !hm.containsKey("KKDKDKD"));
    IdentityHashMap m = new IdentityHashMap();
    m.put(null, "test");
    assertTrue("Failed with null key", m.containsKey(null));
    assertTrue("Failed with missing key matching null hash", !m.containsKey(new Integer(0)));
}
Also used : IdentityHashMap(java.util.IdentityHashMap)

Example 50 with IdentityHashMap

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

the class IdentityHashMapTest method setUp.

/**
     * Sets up the fixture, for example, open a network connection. This method
     * is called before a test is executed.
     */
protected void setUp() {
    objArray = new Object[hmSize];
    objArray2 = new Object[hmSize];
    for (int i = 0; i < objArray.length; i++) {
        objArray[i] = new Integer(i);
        // android-changed: the containsKey test requires unique strings.
        objArray2[i] = new String(objArray[i].toString());
    }
    hm = new IdentityHashMap();
    for (int i = 0; i < objArray.length; i++) hm.put(objArray2[i], objArray[i]);
    hm.put("test", null);
    hm.put(null, "test");
}
Also used : IdentityHashMap(java.util.IdentityHashMap)

Aggregations

IdentityHashMap (java.util.IdentityHashMap)142 Map (java.util.Map)44 HashMap (java.util.HashMap)42 ArrayList (java.util.ArrayList)31 HashSet (java.util.HashSet)20 LinkedHashMap (java.util.LinkedHashMap)18 Collection (java.util.Collection)16 Set (java.util.Set)16 TreeMap (java.util.TreeMap)16 Iterator (java.util.Iterator)14 AbstractMap (java.util.AbstractMap)13 List (java.util.List)11 Test (org.junit.Test)11 DependencyNode (org.sonatype.aether.graph.DependencyNode)10 WeakHashMap (java.util.WeakHashMap)8 LinkedList (java.util.LinkedList)7 TreeSet (java.util.TreeSet)7 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 Tree (edu.stanford.nlp.trees.Tree)6 IOException (java.io.IOException)6