Skip to content

Commit 43b5f3e

Browse files
committed
TypesTest: add tests for Types.field
1 parent 53431c0 commit 43b5f3e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/java/org/scijava/util/TypesTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
import static org.junit.Assert.assertEquals;
3636
import static org.junit.Assert.assertNull;
3737
import static org.junit.Assert.assertSame;
38+
import static org.junit.Assert.assertTrue;
3839
import static org.junit.Assert.fail;
3940

4041
import java.io.Serializable;
4142
import java.lang.reflect.Field;
4243
import java.lang.reflect.Type;
44+
import java.lang.reflect.TypeVariable;
4345
import java.util.HashMap;
4446
import java.util.List;
4547

@@ -180,6 +182,16 @@ public void testRaws() {
180182
Serializable.class, Cloneable.class);
181183
}
182184

185+
/** Tests {@link Types#field}. */
186+
@Test
187+
public void testField() {
188+
final Field field = Types.field(Thing.class, "thing");
189+
assertEquals("thing", field.getName());
190+
assertSame(Object.class, field.getType());
191+
assertTrue(field.getGenericType() instanceof TypeVariable);
192+
assertEquals("T", ((TypeVariable<?>) field.getGenericType()).getName());
193+
}
194+
183195
/** Tests {@link Types#array}. */
184196
@Test
185197
public void testArray() {

0 commit comments

Comments
 (0)