Package java.util

Examples of java.util.IdentityHashMap.containsKey()


    IdentityHashMap map = new IdentityHashMap();
    Object result;

    // null key and null value
    result = map.put(null, null);
    assertTrue("testA can not find null key", map.containsKey(null));
    assertTrue("testA can not find null value", map.containsValue(null));
    assertNull("testA can not get null value for null key",
        map.get(null));
    assertNull("testA put returned wrong value", result);
View Full Code Here


    assertNull("testA put returned wrong value", result);

    // null value
    String value = "a value";
    result = map.put(null, value);
    assertTrue("testB can not find null key", map.containsKey(null));
    assertTrue("testB can not find a value with null key", map
        .containsValue(value));
    assertTrue("testB can not get value for null key",
        map.get(null) == value);
    assertNull("testB put returned wrong value", result);
View Full Code Here

    assertNull("testB put returned wrong value", result);

    // a null key
    String key = "a key";
    result = map.put(key, null);
    assertTrue("testC can not find a key with null value", map
        .containsKey(key));
    assertTrue("testC can not find null value", map.containsValue(null));
    assertNull("testC can not get null value for key", map.get(key));
    assertNull("testC put returned wrong value", result);
View Full Code Here

    assertNull("testC put returned wrong value", result);

    // another null key
    String anothervalue = "another value";
    result = map.put(null, anothervalue);
    assertTrue("testD can not find null key", map.containsKey(null));
    assertTrue("testD can not find a value with null key", map
        .containsValue(anothervalue));
    assertTrue("testD can not get value for null key",
        map.get(null) == anothervalue);
    assertTrue("testD put returned wrong value", result == value);
View Full Code Here

    assertTrue("testD put returned wrong value", result == value);

    // remove a null key
    result = map.remove(null);
    assertTrue("testE remove returned wrong value", result == anothervalue);
    assertTrue("testE should not find null key", !map.containsKey(null));
    assertTrue("testE should not find a value with null key", !map
        .containsValue(anothervalue));
    assertNull("testE should not get value for null key",
        map.get(null));
  }
View Full Code Here

    map.put(null, null);
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.remove("key1");

    assertTrue("Did not remove key1", !map.containsKey("key1"));
    assertTrue("Did not remove the value for key1", !map
        .containsValue("value1"));

    assertTrue("Modified key2", map.get("key2") != null
        && map.get("key2") == "value2");
View Full Code Here

    while (it.hasNext()) {
      Map.Entry entry = (Map.Entry) it.next();
      assertTrue("EntrySetIterator can not find entry ", entries
          .contains(entry));

      assertTrue("entry key not found in map", map.containsKey(entry
          .getKey()));
      assertTrue("entry value not found in map", map.containsValue(entry
          .getValue()));

      assertTrue("entry key not found in the keyset", keyset
View Full Code Here

    map.put(key, value);

    Collection vals = map.values();
    boolean result = vals.remove(key);
    assertTrue("removed entries incorrectly", map.size() == 11 && !result);
    assertTrue("removed key incorrectly", map.containsKey(key));
    assertTrue("removed value incorrectly", map.containsValue(value));

    result = vals.remove(value);
    assertTrue("Did not remove entry as expected", map.size() == 10
        && result);
View Full Code Here

    IdentityHashMap map = new IdentityHashMap();
    Object result;

    // null key and null value
    result = map.put(null, null);
    assertTrue("testA can not find null key", map.containsKey(null));
    assertTrue("testA can not find null value", map.containsValue(null));
    assertNull("testA can not get null value for null key",
        map.get(null));
    assertNull("testA put returned wrong value", result);
View Full Code Here

    assertNull("testA put returned wrong value", result);

    // null value
    String value = "a value";
    result = map.put(null, value);
    assertTrue("testB can not find null key", map.containsKey(null));
    assertTrue("testB can not find a value with null key", map
        .containsValue(value));
    assertTrue("testB can not get value for null key",
        map.get(null) == value);
    assertNull("testB put returned wrong value", result);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.