use of java.util.WeakHashMap in project robovm by robovm.
the class WeakHashMapTest method test_Constructor.
/**
* java.util.WeakHashMap#WeakHashMap()
*/
public void test_Constructor() {
// Test for method java.util.WeakHashMap()
new Support_MapTest2(new WeakHashMap()).runTest();
whm = new WeakHashMap();
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]);
}
use of java.util.WeakHashMap in project robovm by robovm.
the class WeakHashMapTest method test_putAllLjava_util_Map.
/**
* java.util.WeakHashMap#putAll(java.util.Map)
*/
public void test_putAllLjava_util_Map() {
Map mockMap = new MockMap();
WeakHashMap map = new WeakHashMap();
map.putAll(mockMap);
assertEquals("Size should be 0", 0, map.size());
try {
map.putAll(null);
fail("NullPointerException exected");
} catch (NullPointerException e) {
//expected
}
}
use of java.util.WeakHashMap in project robovm by robovm.
the class WeakHashMapTest method test_containsValueLjava_lang_Object.
/**
* java.util.WeakHashMap#containsValue(java.lang.Object)
*/
public void test_containsValueLjava_lang_Object() {
// Test for method boolean java.util.WeakHashMap.containsValue()
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 value", whm.containsValue(valueArray[i]));
keyArray[25] = null;
keyArray[50] = null;
}
use of java.util.WeakHashMap in project robovm by robovm.
the class WeakHashMapTest method test_ConstructorI.
/**
* java.util.WeakHashMap#WeakHashMap(int)
*/
public void test_ConstructorI() {
// Test for method java.util.WeakHashMap(int)
whm = new WeakHashMap(50);
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);
assertNull("Empty weakhashmap access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
try {
new WeakHashMap(-50);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
}
use of java.util.WeakHashMap in project robovm by robovm.
the class WeakHashMapTest method test_removeLjava_lang_Object.
/**
* java.util.WeakHashMap#remove(java.lang.Object)
*/
public void test_removeLjava_lang_Object() {
// Test for method java.lang.Object
// java.util.WeakHashMap.remove(java.lang.Object)
whm = new WeakHashMap();
for (int i = 0; i < 100; i++) whm.put(keyArray[i], valueArray[i]);
assertTrue("Remove returned incorrect value", whm.remove(keyArray[25]) == valueArray[25]);
assertNull("Remove returned incorrect value", whm.remove(keyArray[25]));
assertEquals("Size should be 99 after remove", 99, whm.size());
}
Aggregations