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