83 lines
2.5 KiB
Plaintext
83 lines
2.5 KiB
Plaintext
package speiger.src.testers.PACKAGE.tests.maps;
|
|
|
|
#ignore
|
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
|
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT;
|
|
#endignore
|
|
|
|
import org.junit.Ignore;
|
|
|
|
import com.google.common.collect.testing.features.CollectionSize;
|
|
import com.google.common.collect.testing.features.MapFeature;
|
|
|
|
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
|
|
|
@Ignore
|
|
@SuppressWarnings("javadoc")
|
|
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
|
{
|
|
#ignore
|
|
@MapFeature.Require(SUPPORTS_PUT)
|
|
#endignore
|
|
public void testPutIfAbsent_supportedAbsent() {
|
|
assertEquals("putIfAbsent(notPresent, value) should return INVALID_VALUE", INVALID_VALUE, getMap().putIfAbsent(k3(), v3()));
|
|
expectAdded(e3());
|
|
}
|
|
|
|
#ignore
|
|
@MapFeature.Require(SUPPORTS_PUT)
|
|
@CollectionSize.Require(absent = ZERO)
|
|
#endignore
|
|
public void testPutIfAbsent_supportedPresent() {
|
|
assertEquals("putIfAbsent(present, value) should return existing value", v0(), getMap().putIfAbsent(k0(), v3()));
|
|
expectUnchanged();
|
|
}
|
|
|
|
#ignore
|
|
@MapFeature.Require(SUPPORTS_PUT)
|
|
#endignore
|
|
public void testPutIfAbsent_replaceableDefaultValue() {
|
|
getMap().putIfAbsent(k3(), getMap().getDefaultReturnValue());
|
|
assertEquals("get(present) should return defaultValue value", getMap().getDefaultReturnValue(), get(k3()));
|
|
getMap().putIfAbsent(k3(), v3());
|
|
assertEquals("get(present) value should have been replaced", v3(), get(k3()));
|
|
}
|
|
|
|
#ignore
|
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
#endignore
|
|
public void testPutIfAbsent_unsupportedAbsent() {
|
|
try {
|
|
getMap().putIfAbsent(k3(), v3());
|
|
fail("putIfAbsent(notPresent, value) should throw");
|
|
} catch (UnsupportedOperationException expected) {
|
|
}
|
|
expectUnchanged();
|
|
expectMissing(e3());
|
|
}
|
|
|
|
#ignore
|
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
@CollectionSize.Require(absent = ZERO)
|
|
#endignore
|
|
public void testPutIfAbsent_unsupportedPresentExistingValue() {
|
|
try {
|
|
assertEquals("putIfAbsent(present, existingValue) should return present or throw", v0(), getMap().putIfAbsent(k0(), v0()));
|
|
} catch (UnsupportedOperationException tolerated) {
|
|
}
|
|
expectUnchanged();
|
|
}
|
|
|
|
#ignore
|
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
@CollectionSize.Require(absent = ZERO)
|
|
#endignore
|
|
public void testPutIfAbsent_unsupportedPresentDifferentValue() {
|
|
try {
|
|
getMap().putIfAbsent(k0(), v3());
|
|
} catch (UnsupportedOperationException tolerated) {
|
|
}
|
|
expectUnchanged();
|
|
}
|
|
}
|