-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed tests and added missing changelog
- Loading branch information
Showing
11 changed files
with
620 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
...s/speiger/assets/testers/templates/tests/maps/MapComputeIfAbsentNonDefaultTester.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.