Add AbstractMapTest.testRemoveKeyValue()

This commit is contained in:
Gary Gregory 2024-09-24 18:11:55 -04:00
parent 8d7a701b09
commit aba168c497
1 changed files with 17 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.Serializable;
import java.util.ArrayList;
@ -1810,6 +1811,22 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
verify();
}
/**
* Tests {@link Map#remove(Object, Object)}.
*/
@Test
public void testRemoveKeyValue() {
assumeTrue(isRemoveSupported());
resetFull();
final K[] sampleKeys = getSampleKeys();
final V[] sampleValues = getSampleValues();
assertFalse(getMap().isEmpty());
for (int i = 0; i < sampleKeys.length; i++) {
assertTrue(getMap().remove(sampleKeys[i], sampleValues[i]));
}
assertTrue(getMap().isEmpty());
}
/**
* Test to ensure the test setup is working properly. This method checks to ensure that the getSampleKeys and getSampleValues methods are returning results
* that look appropriate. That is, they both return a non-null array of equal length. The keys array must not have any duplicate values, and may only