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());
}
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]));
}
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));
}
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)));
}
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");
}
Aggregations