use of com.google.common.collect.testing.features.CollectionSize.ZERO 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.CollectionSize.ZERO 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()));
}
use of com.google.common.collect.testing.features.CollectionSize.ZERO in project guava by google.
the class MapComputeIfAbsentTester method testComputeIfAbsent_supportedPresent.
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testComputeIfAbsent_supportedPresent() {
assertEquals("computeIfAbsent(present, function) should return existing value", v0(), getMap().computeIfAbsent(k0(), k -> {
throw new AssertionFailedError();
}));
expectUnchanged();
}
Aggregations