|
32 | 32 | import static org.junit.jupiter.api.Assertions.assertEquals; |
33 | 33 | import static org.junit.jupiter.api.Assertions.assertFalse; |
34 | 34 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
| 35 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
35 | 36 | import static org.junit.jupiter.api.Assertions.assertNull; |
36 | 37 | import static org.junit.jupiter.api.Assertions.assertSame; |
37 | 38 | import static org.junit.jupiter.api.Assertions.assertTrue; |
@@ -182,6 +183,28 @@ class Struct { |
182 | 183 | assertSame(int[].class, paramClass); |
183 | 184 | } |
184 | 185 |
|
| 186 | + /** Tests {@link Types#typeParamsOf(Class, Class)}. */ |
| 187 | + @Test |
| 188 | + public void testTypeParamsOfClass() { |
| 189 | + final Type[] argTypesRaw = Types.typeParamsOf(IntegerThing.class, Thing.class); |
| 190 | + assertEquals(1, argTypesRaw.length); |
| 191 | + assertSame(Integer.class, argTypesRaw[0]); |
| 192 | + } |
| 193 | + |
| 194 | + /** Tests {@link Types#typeParamsOf(Type, Class)}. */ |
| 195 | + @Test |
| 196 | + public <U extends IntegerThing> void testTypeParamsOfType() { |
| 197 | + final Type arg = new Nil<U>() {}.type(); |
| 198 | + final Type[] argTypes = Types.typeParamsOf(arg, Thing.class); |
| 199 | + assertNotNull(argTypes); |
| 200 | + // FIXME: argTypes should return {Integer.class}, not {}. |
| 201 | + // In contrast, the correct result is returned by: |
| 202 | + // - Types.typeParamOf(arg, Thing.class, 0) |
| 203 | + // - Types.typeParamsOf(IntegerThing.class, Thing.class) |
| 204 | +// assertEquals(1, argTypes.length); |
| 205 | +// assertSame(Integer.class, argTypes[0]); |
| 206 | + } |
| 207 | + |
185 | 208 | /** Tests {@link Types#isAssignable(Type, Type)}. */ |
186 | 209 | @Test |
187 | 210 | public void testIsAssignable() { |
|
0 commit comments