Update testMapEntry() for LANG-1736

This commit is contained in:
Gary Gregory 2024-05-22 11:28:44 -04:00
parent 82d91299f3
commit 0e42557d4a
1 changed files with 12 additions and 3 deletions

View File

@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang3.AbstractLangTest;
import org.junit.jupiter.api.Test;
@ -101,6 +102,11 @@ public class PairTest extends AbstractLangTest {
assertNotEquals(pair.hashCode(), pair2.hashCode());
}
@Test
public void testConcurrentHashMapEntry() {
testMapEntry(new ConcurrentHashMap<>());
}
@Test
public void testEmptyArrayGenerics() {
final Pair<Integer, String>[] empty = Pair.emptyArray();
@ -127,11 +133,14 @@ public class PairTest extends AbstractLangTest {
}
@Test
public void testMapEntry() {
final Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
final HashMap<Integer, String> map = new HashMap<>();
public void testHashMapEntry() {
testMapEntry(new HashMap<>());
}
private void testMapEntry(final Map<Integer, String> map) {
map.put(0, "foo");
final Entry<Integer, String> entry = map.entrySet().iterator().next();
final Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
assertEquals(pair, entry);
assertEquals(pair.hashCode(), entry.hashCode());
// LANG-1736: