Add test_LANG_1698

This commit is contained in:
Gary Gregory 2023-07-23 08:24:33 -04:00
parent c455ea2832
commit 6782d1daf8
1 changed files with 13 additions and 1 deletions

View File

@ -35,8 +35,10 @@ import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -272,6 +274,16 @@ public class TypeUtilsTest<B> extends AbstractLangTest {
assertEquals("T extends java.lang.Enum<T>", TypeUtils.toString(method.getGenericReturnType()));
}
@Test
public void test_LANG_1698() {
ParameterizedType comparing = (ParameterizedType) Arrays.stream(Comparator.class.getDeclaredMethods())
.filter(k -> k.getName().equals("comparing")).findFirst()
.orElse(Comparator.class.getDeclaredMethods()[0]).getGenericParameterTypes()[0];
final String typeName = TypeUtils
.parameterize((Class<?>) comparing.getRawType(), comparing.getActualTypeArguments()).getTypeName();
assertEquals("java.util.function.Function<? super T, ? extends U>", typeName);
}
@Test
public void test_LANG_820() {
final Type[] typeArray = {String.class, String.class};
@ -1048,7 +1060,7 @@ public class TypeUtilsTest<B> extends AbstractLangTest {
assertEquals(String.format("? extends %s", String.class.getName()), TypeUtils.toString(simpleWildcard));
assertEquals(String.format("? extends %s", String.class.getName()), simpleWildcard.toString());
}
@Test
public void testWrap() {
final Type t = getClass().getTypeParameters()[0];