use of com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT in project guava by google.
the class MapComputeIfPresentTester method testComputeIfPresent_nullKeySupportedAbsent.
@MapFeature.Require({ SUPPORTS_PUT, ALLOWS_NULL_KEYS })
public void testComputeIfPresent_nullKeySupportedAbsent() {
assertNull("computeIfPresent(null, function) should return null", getMap().computeIfPresent(null, (k, v) -> {
throw new AssertionFailedError();
}));
expectUnchanged();
}
use of com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT in project guava by google.
the class MapComputeIfPresentTester method testComputeIfPresent_nullTreatedAsAbsent.
@MapFeature.Require({ SUPPORTS_PUT, ALLOWS_NULL_VALUES })
@CollectionSize.Require(absent = ZERO)
public void testComputeIfPresent_nullTreatedAsAbsent() {
initMapWithNullValue();
assertNull("computeIfPresent(presentAssignedToNull, function) should return null", getMap().computeIfPresent(getKeyForNullValue(), (k, v) -> {
throw new AssertionFailedError();
}));
expectReplacement(entry(getKeyForNullValue(), null));
}
use of com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT in project guava by google.
the class MapComputeIfPresentTester method testComputeIfPresent_supportedAbsent.
@MapFeature.Require(SUPPORTS_PUT)
public void testComputeIfPresent_supportedAbsent() {
assertNull("computeIfPresent(notPresent, function) should return null", getMap().computeIfPresent(k3(), (k, v) -> {
throw new AssertionFailedError();
}));
expectUnchanged();
}
use of com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT in project guava by google.
the class MapMergeTester method testAbsent.
@MapFeature.Require(SUPPORTS_PUT)
public void testAbsent() {
assertEquals("Map.merge(absent, value, function) should return value", v3(), getMap().merge(k3(), v3(), (oldV, newV) -> {
throw new AssertionFailedError("Should not call merge function if key was absent");
}));
expectAdded(e3());
}
use of com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT in project guava by google.
the class MapMergeTester method testMappedToNull.
@MapFeature.Require({ SUPPORTS_PUT, ALLOWS_NULL_VALUES })
@CollectionSize.Require(absent = ZERO)
public void testMappedToNull() {
initMapWithNullValue();
assertEquals("Map.merge(keyMappedToNull, value, function) should return value", v3(), getMap().merge(getKeyForNullValue(), v3(), (oldV, newV) -> {
throw new AssertionFailedError("Should not call merge function if key was mapped to null");
}));
expectReplacement(entry(getKeyForNullValue(), v3()));
}
Aggregations