use of java.util.IdentityHashMap in project j2objc by google.
the class AbstractMapTest method test_keySet.
/**
* @tests java.util.AbstractMap#keySet()
*/
public void test_keySet() {
AbstractMap map1 = new HashMap(0);
assertSame("HashMap(0)", map1.keySet(), map1.keySet());
AbstractMap map2 = new HashMap(10);
assertSame("HashMap(10)", map2.keySet(), map2.keySet());
Map map3 = Collections.EMPTY_MAP;
assertSame("EMPTY_MAP", map3.keySet(), map3.keySet());
AbstractMap map4 = new IdentityHashMap(1);
assertSame("IdentityHashMap", map4.keySet(), map4.keySet());
AbstractMap map5 = new LinkedHashMap(122);
assertSame("LinkedHashMap", map5.keySet(), map5.keySet());
AbstractMap map6 = new TreeMap();
assertSame("TreeMap", map6.keySet(), map6.keySet());
}
use of java.util.IdentityHashMap in project j2objc by google.
the class AbstractMapTest method test_values.
/**
* @tests java.util.AbstractMap#values()
*/
public void test_values() {
AbstractMap map1 = new HashMap(0);
assertSame("HashMap(0)", map1.values(), map1.values());
AbstractMap map2 = new HashMap(10);
assertSame("HashMap(10)", map2.values(), map2.values());
Map map3 = Collections.EMPTY_MAP;
assertSame("EMPTY_MAP", map3.values(), map3.values());
AbstractMap map4 = new IdentityHashMap(1);
assertSame("IdentityHashMap", map4.values(), map4.values());
AbstractMap map5 = new LinkedHashMap(122);
assertSame("IdentityHashMap", map5.values(), map5.values());
AbstractMap map6 = new TreeMap();
assertSame("TreeMap", map6.values(), map6.values());
}
use of java.util.IdentityHashMap in project j2objc by google.
the class IdentityHashMapTest method test_keyset_remove.
/**
* @tests java.util.IdentityHashMap#keySet()
* @tests java.util.IdentityHashMap#remove(java.lang.Object)
*/
public void test_keyset_remove() {
IdentityHashMap map = new IdentityHashMap();
Integer key = new Integer(21);
map.put(new Integer(1), null);
map.put(new Integer(11), null);
map.put(key, null);
map.put(new Integer(31), null);
map.put(new Integer(41), null);
map.put(new Integer(51), null);
map.put(new Integer(61), null);
map.put(new Integer(71), null);
map.put(new Integer(81), null);
map.put(new Integer(91), null);
Set set = map.keySet();
Set newset = new HashSet();
Iterator it = set.iterator();
while (it.hasNext()) {
Object element = it.next();
if (element == key) {
it.remove();
} else
newset.add(element);
}
int size = newset.size();
assertTrue("keyset and newset don't have same size", newset.size() == size);
assertTrue("element is in newset ", !newset.contains(key));
assertTrue("element not removed from keyset", !set.contains(key));
assertTrue("element not removed from map", !map.containsKey(key));
assertTrue("newset and keyset do not have same elements 1", newset.equals(set));
assertTrue("newset and keyset do not have same elements 2", set.equals(newset));
}
use of java.util.IdentityHashMap in project j2objc by google.
the class IdentityHashMapTest method test_clone_scenario4.
public void test_clone_scenario4() {
IdentityHashMap hashMap = new IdentityHashMap();
Object cloneHashMap = hashMap.clone();
assertNull(((IdentityHashMap) cloneHashMap).get((Object) null));
hashMap.put((Object) null, cloneHashMap);
assertNull(((IdentityHashMap) cloneHashMap).get((Object) null));
assertEquals(cloneHashMap, hashMap.get((Object) null));
}
use of java.util.IdentityHashMap in project j2objc by google.
the class IdentityHashMapTest method test_clone_scenario2.
public void test_clone_scenario2() {
IdentityHashMap hashMap = new IdentityHashMap();
assertEquals(0, hashMap.hashCode());
Object cloneHashMap = hashMap.clone();
hashMap.put("key", "value");
assertEquals(1, hashMap.size());
assertEquals(0, ((IdentityHashMap) cloneHashMap).size());
assertEquals("value", hashMap.get("key"));
assertNull(((IdentityHashMap) cloneHashMap).get("key"));
assertTrue(0 != hashMap.hashCode());
assertEquals(0, cloneHashMap.hashCode());
}
Aggregations