コード例 #1
0
  @Test
  public void rehash_null_collision() {
    if (this.newMap() instanceof ConcurrentMap || this.newMap() instanceof SortedMap) {
      return;
    }
    MutableMapIterable<IntegerWithCast, String> mutableMapIterable =
        this.newMapWithKeyValue(null, null);

    for (int i = 0; i < 256; i++) {
      mutableMapIterable.put(new IntegerWithCast(i), String.valueOf(i));
    }
  }
コード例 #2
0
  @Test
  public void removeNullFromValues() {
    if (this.newMap() instanceof ConcurrentMap) {
      return;
    }

    MutableMapIterable<String, Integer> map =
        this.newMapWithKeysValues("One", 1, "Two", 2, "Three", 3);
    Assert.assertFalse(map.values().remove(null));
    Assert.assertEquals(UnifiedMap.newWithKeysValues("One", 1, "Two", 2, "Three", 3), map);
    map.put("Four", null);
    Assert.assertTrue(map.values().remove(null));
    Assert.assertEquals(UnifiedMap.newWithKeysValues("One", 1, "Two", 2, "Three", 3), map);
  }
コード例 #3
0
  @Test
  public void put() {
    MutableMapIterable<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two");
    Assert.assertNull(map.put(3, "Three"));
    Assert.assertEquals(UnifiedMap.newWithKeysValues(1, "One", 2, "Two", 3, "Three"), map);

    ImmutableList<Integer> key1 = Lists.immutable.with(null);
    ImmutableList<Integer> key2 = Lists.immutable.with(null);
    Object value1 = new Object();
    Object value2 = new Object();
    MutableMapIterable<ImmutableList<Integer>, Object> map2 = this.newMapWithKeyValue(key1, value1);
    Object previousValue = map2.put(key2, value2);
    Assert.assertSame(value1, previousValue);
    Assert.assertSame(key1, map2.keysView().getFirst());
  }