Fixed tests and added missing changelog
This commit is contained in:
parent
274d37c4d6
commit
640a1a8161
|
@ -12,6 +12,7 @@
|
|||
- Added: Iterators/Async Builders now support MapToPrimitiveType function on the object variant. So more processing can be done. (Will be expanded upon later versions)
|
||||
- Fixed: SetValue wasn't working on forEach implementations.
|
||||
- Fixed: Compute functions now perform with primitives more java compliant. Meaning that getDefaultReturnValue function no longer is seen as null.
|
||||
- Fixed: Supplier was using the wrong dataType in their function name.
|
||||
- Updated: SimpleCodeGenerator 1.3.0 is now being used which allows for iterative code support.
|
||||
|
||||
### Version 0.8.0
|
||||
|
|
|
@ -108,6 +108,9 @@ public class MapModule extends BaseModule
|
|||
addBlockedFiles("TestOrderedMapGenerator");
|
||||
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||
}
|
||||
if(valueType == ClassType.OBJECT) {
|
||||
addBlockedFiles("MapComputeIfAbsentNonDefaultTester", "MapComputeIfPresentNonDefaultTester", "MapComputeNonDefaultTester", "MapSupplyIfAbsentNonDefaultTester");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -158,6 +161,9 @@ public class MapModule extends BaseModule
|
|||
addBiRequirement("MapComputeIfAbsentTester");
|
||||
addBiRequirement("MapComputeIfPresentTester");
|
||||
addBiRequirement("MapComputeTester");
|
||||
addBiRequirement("MapComputeIfAbsentNonDefaultTester");
|
||||
addBiRequirement("MapComputeIfPresentNonDefaultTester");
|
||||
addBiRequirement("MapComputeNonDefaultTester");
|
||||
addBiRequirement("MapCopyTester");
|
||||
addBiRequirement("MapContainsTester");
|
||||
addBiRequirement("MapContainsKeyTester");
|
||||
|
@ -184,6 +190,7 @@ public class MapModule extends BaseModule
|
|||
addBiRequirement("MapReplaceTester");
|
||||
addBiRequirement("MapSizeTester");
|
||||
addBiRequirement("MapSupplyIfAbsentTester");
|
||||
addBiRequirement("MapSupplyIfAbsentNonDefaultTester");
|
||||
addBiRequirement("MapToStringTester");
|
||||
addBiRequirement("NavigableMapNavigationTester");
|
||||
addBiRequirement("SortedMapNavigationTester");
|
||||
|
|
|
@ -53,6 +53,11 @@ import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCl
|
|||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
||||
#if !VALUE_OBJECT
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
||||
|
@ -78,6 +83,9 @@ import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRe
|
|||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
||||
#if !VALUE_OBJECT
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||
|
@ -105,6 +113,12 @@ public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder
|
|||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
||||
#if !VALUE_OBJECT
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester.class);
|
||||
#endif
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
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
|
||||
#if !VALUE_BOOLEAN
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
#endignore
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.common.collect.testing.features.MapFeature;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_supportedAbsent() {
|
||||
#if VALUE_BOOLEAN
|
||||
getMap().setDefaultReturnValue(true);
|
||||
#endif
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||
assertEquals(k3(), k);
|
||||
return v3();
|
||||
}));
|
||||
expectAdded(e3());
|
||||
}
|
||||
|
||||
#if !VALUE_BOOLEAN
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_supportedAbsentFirst() {
|
||||
getMap().setDefaultReturnValue(v0());
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
assertEquals(k0(), k);
|
||||
return v3();
|
||||
}));
|
||||
expectContents(entry(k0(), v3()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_supportedAbsentSameResult() {
|
||||
getMap().setDefaultReturnValue(v0());
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
assertEquals(k0(), k);
|
||||
return v0();
|
||||
}));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#endif
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_supportedPresent() {
|
||||
assertEquals("COMPUTE_IF_ABSENT(present, function) should return existing value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
throw new AssertionFailedError();
|
||||
}));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_functionReturnsNullNotInserted() {
|
||||
assertEquals("COMPUTE_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||
assertEquals(k3(), k);
|
||||
return INVALID_VALUE;
|
||||
}));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
static class ExpectedException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_functionThrows() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||
assertEquals(k3(), k);
|
||||
throw new ExpectedException();
|
||||
});
|
||||
fail("Expected ExpectedException");
|
||||
} catch (ExpectedException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_unsupportedAbsent() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||
// allowed to be called
|
||||
assertEquals(k3(), k);
|
||||
return v3();
|
||||
});
|
||||
fail("COMPUTE_IF_ABSENT(notPresent, function) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_unsupportedPresentExistingValue() {
|
||||
try {
|
||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
assertEquals(k0(), k);
|
||||
return v0();
|
||||
}));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_unsupportedPresentDifferentValue() {
|
||||
try {
|
||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
assertEquals(k0(), k);
|
||||
return v3();
|
||||
}));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_supportedAbsent() {
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
||||
assertEquals(k3(), k);
|
||||
return v3();
|
||||
}));
|
||||
|
@ -40,11 +40,19 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||
#endignore
|
||||
public void testComputeIfAbsent_supportedAbsentFirst() {
|
||||
getMap().setDefaultReturnValue(v0());
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
#if VALUE_OBJECT
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||
assertEquals(k0(), k);
|
||||
return v3();
|
||||
}));
|
||||
expectContents(entry(k0(), v3()));
|
||||
#else
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||
assertEquals(k0(), k);
|
||||
return v3();
|
||||
}));
|
||||
expectUnchanged();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ignore
|
||||
|
@ -53,7 +61,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||
#endignore
|
||||
public void testComputeIfAbsent_supportedAbsentSameResult() {
|
||||
getMap().setDefaultReturnValue(v0());
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||
assertEquals(k0(), k);
|
||||
return v0();
|
||||
}));
|
||||
|
@ -66,7 +74,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_supportedPresent() {
|
||||
assertEquals("COMPUTE_IF_ABSENT(present, function) should return existing value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
assertEquals("COMPUTE_IF_ABSENT(present, function) should return existing value", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||
throw new AssertionFailedError();
|
||||
}));
|
||||
expectUnchanged();
|
||||
|
@ -76,11 +84,15 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testComputeIfAbsent_functionReturnsNullNotInserted() {
|
||||
assertEquals("COMPUTE_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||
assertEquals("COMPUTE_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
||||
assertEquals(k3(), k);
|
||||
return INVALID_VALUE;
|
||||
}));
|
||||
#if VALUE_OBJECT
|
||||
expectUnchanged();
|
||||
#else
|
||||
expectAdded(entry(k3(), INVALID_VALUE));
|
||||
#endif
|
||||
}
|
||||
|
||||
static class ExpectedException extends RuntimeException {
|
||||
|
@ -92,7 +104,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||
#endignore
|
||||
public void testComputeIfAbsent_functionThrows() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||
getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
||||
assertEquals(k3(), k);
|
||||
throw new ExpectedException();
|
||||
});
|
||||
|
@ -107,7 +119,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||
#endignore
|
||||
public void testComputeIfAbsent_unsupportedAbsent() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||
getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
||||
// allowed to be called
|
||||
assertEquals(k3(), k);
|
||||
return v3();
|
||||
|
@ -124,7 +136,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||
#endignore
|
||||
public void testComputeIfAbsent_unsupportedPresentExistingValue() {
|
||||
try {
|
||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||
assertEquals(k0(), k);
|
||||
return v0();
|
||||
}));
|
||||
|
@ -139,7 +151,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||
#endignore
|
||||
public void testComputeIfAbsent_unsupportedPresentDifferentValue() {
|
||||
try {
|
||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||
assertEquals(k0(), k);
|
||||
return v3();
|
||||
}));
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
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 junit.framework.AssertionFailedError;
|
||||
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testComputeIfPresent_supportedAbsent() {
|
||||
assertEquals("COMPUTE_IF_PRESENT(notPresent, function) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
||||
throw new AssertionFailedError();
|
||||
}));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#if !VALUE_BOOLEAN
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfPresent_supportedPresent() {
|
||||
assertEquals("COMPUTE_IF_PRESENT(present, function) should return new value", v3(), getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
return v3();
|
||||
}));
|
||||
expectReplacement(entry(k0(), v3()));
|
||||
}
|
||||
|
||||
#endif
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfPresent_functionReturnsNull() {
|
||||
assertEquals("COMPUTE_IF_PRESENT(present, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
return INVALID_VALUE;
|
||||
}));
|
||||
expectMissing(e0());
|
||||
}
|
||||
|
||||
static class ExpectedException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfPresent_functionThrows() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
throw new ExpectedException();
|
||||
});
|
||||
fail("Expected ExpectedException");
|
||||
} catch (ExpectedException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testComputeIfPresent_unsupportedAbsent() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
||||
throw new AssertionFailedError();
|
||||
});
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfPresent_unsupportedPresent() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> v3());
|
||||
fail("Expected UnsupportedOperationException");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testComputeIfPresent_supportedAbsent() {
|
||||
assertEquals("COMPUTE_IF_PRESENT(notPresent, function) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
||||
assertEquals("COMPUTE_IF_PRESENT(notPresent, function) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENT(k3(), (k, v) -> {
|
||||
throw new AssertionFailedError();
|
||||
}));
|
||||
expectUnchanged();
|
||||
|
@ -32,7 +32,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfPresent_supportedPresent() {
|
||||
assertEquals("COMPUTE_IF_PRESENT(present, function) should return new value", v3(), getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||
assertEquals("COMPUTE_IF_PRESENT(present, function) should return new value", v3(), getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
return v3();
|
||||
|
@ -45,7 +45,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testComputeIfPresent_functionReturnsNull() {
|
||||
assertEquals("COMPUTE_IF_PRESENT(present, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||
assertEquals("COMPUTE_IF_PRESENT(present, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
return INVALID_VALUE;
|
||||
|
@ -63,7 +63,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||
#endignore
|
||||
public void testComputeIfPresent_functionThrows() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||
getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
throw new ExpectedException();
|
||||
|
@ -79,7 +79,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||
#endignore
|
||||
public void testComputeIfPresent_unsupportedAbsent() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
||||
getMap().COMPUTE_IF_PRESENT(k3(), (k, v) -> {
|
||||
throw new AssertionFailedError();
|
||||
});
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
|
@ -93,7 +93,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||
#endignore
|
||||
public void testComputeIfPresent_unsupportedPresent() {
|
||||
try {
|
||||
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> v3());
|
||||
getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> v3());
|
||||
fail("Expected UnsupportedOperationException");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
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;
|
||||
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE;
|
||||
#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_TYPEMapComputeNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
#if !VALUE_BOOLEAN
|
||||
#ignore
|
||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||
#endignore
|
||||
public void testCompute_absentToPresent() {
|
||||
assertEquals("Map.COMPUTE(absent, functionReturningValue) should return value", v3(), getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
return v3();
|
||||
}));
|
||||
expectAdded(e3());
|
||||
assertEquals(getNumElements() + 1, getMap().size());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||
#endignore
|
||||
public void testCompute_absentToAbsent() {
|
||||
assertEquals("Map.COMPUTE(absent, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
return INVALID_VALUE;
|
||||
}));
|
||||
expectUnchanged();
|
||||
assertEquals(getNumElements(), getMap().size());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testCompute_presentToPresent() {
|
||||
#if VALUE_BOOLEAN
|
||||
getMap().setDefaultReturnValue(true);
|
||||
#endif
|
||||
assertEquals("Map.COMPUTE(present, functionReturningValue) should return new value", v3(), getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
return v3();
|
||||
}));
|
||||
expectReplacement(entry(k0(), v3()));
|
||||
assertEquals(getNumElements(), getMap().size());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testCompute_presentToAbsent() {
|
||||
assertEquals("Map.COMPUTE(present, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
return INVALID_VALUE;
|
||||
}));
|
||||
expectMissing(e0());
|
||||
expectMissingKeys(k0());
|
||||
assertEquals(getNumElements() - 1, getMap().size());
|
||||
}
|
||||
|
||||
static class ExpectedException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testCompute_presentFunctionThrows() {
|
||||
try {
|
||||
getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
throw new ExpectedException();
|
||||
});
|
||||
fail("Expected ExpectedException");
|
||||
} catch (ExpectedException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||
#endignore
|
||||
public void testCompute_absentFunctionThrows() {
|
||||
try {
|
||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
throw new ExpectedException();
|
||||
});
|
||||
fail("Expected ExpectedException");
|
||||
} catch (ExpectedException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testCompute_removeAbsent() {
|
||||
try {
|
||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
return INVALID_VALUE;
|
||||
});
|
||||
fail("Expected UnsupportedOperationException");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testCompute_putAbsent() {
|
||||
try {
|
||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
return INVALID_VALUE;
|
||||
});
|
||||
fail("Expected UnsupportedOperationException");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||
#endignore
|
||||
public void testCompute_absentToPresent() {
|
||||
assertEquals("Map.COMPUTE(absent, functionReturningValue) should return value", v3(), getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
assertEquals("Map.COMPUTE(absent, functionReturningValue) should return value", v3(), getMap().COMPUTE(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
return v3();
|
||||
|
@ -34,13 +34,18 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||
#endignore
|
||||
public void testCompute_absentToAbsent() {
|
||||
assertEquals("Map.COMPUTE(absent, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
assertEquals("Map.COMPUTE(absent, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
return INVALID_VALUE;
|
||||
}));
|
||||
#if VALUE_OBJECT
|
||||
expectUnchanged();
|
||||
assertEquals(getNumElements(), getMap().size());
|
||||
#else
|
||||
expectAdded(entry(k3(), INVALID_VALUE));
|
||||
assertEquals(getNumElements()+1, getMap().size());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ignore
|
||||
|
@ -48,7 +53,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testCompute_presentToPresent() {
|
||||
assertEquals("Map.COMPUTE(present, functionReturningValue) should return new value", v3(), getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||
assertEquals("Map.COMPUTE(present, functionReturningValue) should return new value", v3(), getMap().COMPUTE(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
return v3();
|
||||
|
@ -62,14 +67,19 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testCompute_presentToAbsent() {
|
||||
assertEquals("Map.COMPUTE(present, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||
assertEquals("Map.COMPUTE(present, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
return INVALID_VALUE;
|
||||
}));
|
||||
#if VALUE_OBJECT
|
||||
expectMissing(e0());
|
||||
expectMissingKeys(k0());
|
||||
assertEquals(getNumElements() - 1, getMap().size());
|
||||
#else
|
||||
expectReplacement(entry(k0(), INVALID_VALUE));
|
||||
assertEquals(getNumElements(), getMap().size());
|
||||
#endif
|
||||
}
|
||||
|
||||
static class ExpectedException extends RuntimeException {
|
||||
|
@ -82,7 +92,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||
#endignore
|
||||
public void testCompute_presentFunctionThrows() {
|
||||
try {
|
||||
getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||
getMap().COMPUTE(k0(), (k, v) -> {
|
||||
assertEquals(k0(), k);
|
||||
assertEquals(v0(), v);
|
||||
throw new ExpectedException();
|
||||
|
@ -98,7 +108,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||
#endignore
|
||||
public void testCompute_absentFunctionThrows() {
|
||||
try {
|
||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
getMap().COMPUTE(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
throw new ExpectedException();
|
||||
|
@ -114,7 +124,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||
#endignore
|
||||
public void testCompute_removeAbsent() {
|
||||
try {
|
||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
getMap().COMPUTE(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
return INVALID_VALUE;
|
||||
|
@ -130,7 +140,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||
#endignore
|
||||
public void testCompute_putAbsent() {
|
||||
try {
|
||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||
getMap().COMPUTE(k3(), (k, v) -> {
|
||||
assertEquals(k3(), k);
|
||||
assertEquals(INVALID_VALUE, v);
|
||||
return INVALID_VALUE;
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
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
|
||||
#if !VALUE_BOOLEAN
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
#endignore
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.common.collect.testing.features.MapFeature;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_supportedAbsent() {
|
||||
#if VALUE_BOOLEAN
|
||||
getMap().setDefaultReturnValue(true);
|
||||
#endif
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3));
|
||||
expectAdded(e3());
|
||||
}
|
||||
|
||||
#if !VALUE_BOOLEAN
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_supportedAbsentFirst() {
|
||||
getMap().setDefaultReturnValue(v0());
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
||||
expectContents(entry(k0(), v3()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_supportedAbsentSameResult() {
|
||||
getMap().setDefaultReturnValue(v0());
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#endif
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_supportedPresent() {
|
||||
assertEquals("SUPPLY_IF_ABSENT(present, function) should return existing value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), () -> {
|
||||
throw new AssertionFailedError();
|
||||
}));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_functionReturnsNullNotInserted() {
|
||||
assertEquals("SUPPLY_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> INVALID_VALUE));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
static class ExpectedException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_functionThrows() {
|
||||
try {
|
||||
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> {
|
||||
throw new ExpectedException();
|
||||
});
|
||||
fail("Expected ExpectedException");
|
||||
} catch (ExpectedException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_unsupportedAbsent() {
|
||||
try {
|
||||
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3);
|
||||
fail("SUPPLY_IF_ABSENT(notPresent, function) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_unsupportedPresentExistingValue() {
|
||||
try {
|
||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_unsupportedPresentDifferentValue() {
|
||||
try {
|
||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_supportedAbsent() {
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3));
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENT(k3(), this::v3));
|
||||
expectAdded(e3());
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,13 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||
#endignore
|
||||
public void testSupplyIfAbsent_supportedAbsentFirst() {
|
||||
getMap().setDefaultReturnValue(v0());
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
||||
#if VALUE_OBJECT
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENT(k0(), this::v3));
|
||||
expectContents(entry(k0(), v3()));
|
||||
#else
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v3));
|
||||
expectUnchanged();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ignore
|
||||
|
@ -47,7 +52,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||
#endignore
|
||||
public void testSupplyIfAbsent_supportedAbsentSameResult() {
|
||||
getMap().setDefaultReturnValue(v0());
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v0));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
|
@ -57,7 +62,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_supportedPresent() {
|
||||
assertEquals("SUPPLY_IF_ABSENT(present, function) should return existing value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), () -> {
|
||||
assertEquals("SUPPLY_IF_ABSENT(present, function) should return existing value", v0(), getMap().SUPPLY_IF_ABSENT(k0(), () -> {
|
||||
throw new AssertionFailedError();
|
||||
}));
|
||||
expectUnchanged();
|
||||
|
@ -67,8 +72,12 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||
@MapFeature.Require(SUPPORTS_PUT)
|
||||
#endignore
|
||||
public void testSupplyIfAbsent_functionReturnsNullNotInserted() {
|
||||
assertEquals("SUPPLY_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> INVALID_VALUE));
|
||||
assertEquals("SUPPLY_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().SUPPLY_IF_ABSENT(k3(), () -> INVALID_VALUE));
|
||||
#if VALUE_OBJECT
|
||||
expectUnchanged();
|
||||
#else
|
||||
expectAdded(entry(k3(), INVALID_VALUE));
|
||||
#endif
|
||||
}
|
||||
|
||||
static class ExpectedException extends RuntimeException {
|
||||
|
@ -80,7 +89,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||
#endignore
|
||||
public void testSupplyIfAbsent_functionThrows() {
|
||||
try {
|
||||
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> {
|
||||
getMap().SUPPLY_IF_ABSENT(k3(), () -> {
|
||||
throw new ExpectedException();
|
||||
});
|
||||
fail("Expected ExpectedException");
|
||||
|
@ -94,7 +103,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||
#endignore
|
||||
public void testSupplyIfAbsent_unsupportedAbsent() {
|
||||
try {
|
||||
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3);
|
||||
getMap().SUPPLY_IF_ABSENT(k3(), this::v3);
|
||||
fail("SUPPLY_IF_ABSENT(notPresent, function) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
|
@ -107,7 +116,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||
#endignore
|
||||
public void testSupplyIfAbsent_unsupportedPresentExistingValue() {
|
||||
try {
|
||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v0));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
|
@ -119,7 +128,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||
#endignore
|
||||
public void testSupplyIfAbsent_unsupportedPresentDifferentValue() {
|
||||
try {
|
||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v3));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
|
|
Loading…
Reference in New Issue