/** putAll adds all key-value pairs from the given map */ public void testDescendingPutAll() { ConcurrentNavigableMap empty = dmap0(); ConcurrentNavigableMap map = dmap5(); empty.putAll(map); assertEquals(5, empty.size()); assertTrue(empty.containsKey(m1)); assertTrue(empty.containsKey(m2)); assertTrue(empty.containsKey(m3)); assertTrue(empty.containsKey(m4)); assertTrue(empty.containsKey(m5)); }
/** remove(key,value) removes only if pair present */ public void testDescendingRemove2() { ConcurrentNavigableMap map = dmap5(); assertTrue(map.containsKey(m5)); assertEquals("E", map.get(m5)); map.remove(m5, "E"); assertEquals(4, map.size()); assertFalse(map.containsKey(m5)); map.remove(m4, "A"); assertEquals(4, map.size()); assertTrue(map.containsKey(m4)); }
/** remove(key,value) removes only if pair present */ public void testRemove2() { ConcurrentNavigableMap map = map5(); assertTrue(map.containsKey(five)); assertEquals("E", map.get(five)); map.remove(five, "E"); assertEquals(4, map.size()); assertFalse(map.containsKey(five)); map.remove(four, "A"); assertEquals(4, map.size()); assertTrue(map.containsKey(four)); }
/** putAll adds all key-value pairs from the given map */ public void testPutAll() { ConcurrentNavigableMap empty = map0(); ConcurrentNavigableMap map = map5(); empty.putAll(map); assertEquals(5, empty.size()); assertTrue(empty.containsKey(one)); assertTrue(empty.containsKey(two)); assertTrue(empty.containsKey(three)); assertTrue(empty.containsKey(four)); assertTrue(empty.containsKey(five)); }
public void testSubMapContents2() { ConcurrentNavigableMap map = map5(); SortedMap sm = map.subMap(two, three); assertEquals(1, sm.size()); assertEquals(two, sm.firstKey()); assertEquals(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer) (i.next()); assertEquals(two, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); assertEquals(4, map.size()); }
public void testDescendingSubMapContents2() { ConcurrentNavigableMap map = dmap5(); SortedMap sm = map.subMap(m2, m3); assertEquals(1, sm.size()); assertEquals(m2, sm.firstKey()); assertEquals(m2, sm.lastKey()); assertFalse(sm.containsKey(m1)); assertTrue(sm.containsKey(m2)); assertFalse(sm.containsKey(m3)); assertFalse(sm.containsKey(m4)); assertFalse(sm.containsKey(m5)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer) (i.next()); assertEquals(m2, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(m2)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(m3), null); assertEquals(4, map.size()); }
/** containsKey(null) of nonempty map throws NPE */ public void testContainsKey_NullPointerException() { try { ConcurrentNavigableMap c = map5(); c.containsKey(null); shouldThrow(); } catch (NullPointerException success) { } }
/** remove removes the correct key-value pair from the map */ public void testDescendingRemove() { ConcurrentNavigableMap map = dmap5(); map.remove(m5); assertEquals(4, map.size()); assertFalse(map.containsKey(m5)); }
/** containsKey returns true for contained key */ public void testContainsKey() { ConcurrentNavigableMap map = map5(); assertTrue(map.containsKey(one)); assertFalse(map.containsKey(zero)); }
/** replace fails when the given key is not present */ public void testDescendingReplace() { ConcurrentNavigableMap map = dmap5(); assertNull(map.replace(six, "Z")); assertFalse(map.containsKey(six)); }
/** putIfAbsent works when the given key is not present */ public void testDescendingPutIfAbsent() { ConcurrentNavigableMap map = dmap5(); map.putIfAbsent(six, "Z"); assertTrue(map.containsKey(six)); }
/** containsKey returns true for contained key */ public void testDescendingContainsKey() { ConcurrentNavigableMap map = dmap5(); assertTrue(map.containsKey(m1)); assertFalse(map.containsKey(zero)); }
/** remove removes the correct key-value pair from the map */ public void testRemove() { ConcurrentNavigableMap map = map5(); map.remove(five); assertEquals(4, map.size()); assertFalse(map.containsKey(five)); }