8000 Added tests for Typed Collection functions. · randomcoding/JavaUtilities@95d9857 · GitHub
[go: up one dir, main page]

Skip to content

Commit 95d9857

Browse files
author
Tym the Enchanter
committed
Added tests for Typed Collection functions.
1 parent 1e4794b commit 95d9857

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

RandomCodingJavaUtilitiesTests/tests/uk/co/randomcoding/java/util/collection/TypedCollectionUtilitiesTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*
1818
* @author Tym the Enchanter <tymtheenchanter@randomcoding.co.uk>
1919
*/
20+
@SuppressWarnings("synthetic-access")
2021
public class TypedCollectionUtilitiesTest
2122
{
2223
@Test
@@ -33,6 +34,22 @@ public void testExtractTypedCollection() throws Exception
3334
assertThat(TypedCollectionUtilities.extractTypedCollection(testCollection, TestSubClass.class), hasSize(4));
3435
assertThat(TypedCollectionUtilities.extractTypedCollection(testCollection, TestSubSubClass.class), hasSize(2));
3536
assertThat(TypedCollectionUtilities.extractTypedCollection(testCollection, OtherTestClass.class), Matchers.<OtherTestClass> empty());
37+
assertThat(TypedCollectionUtilities.extractTypedCollection(testCollection, OtherTestSubClass.class), Matchers.<OtherTestSubClass> empty());
38+
assertThat(TypedCollectionUtilities.extractTypedCollection(testCollection, Object.class), hasSize(6));
39+
}
40+
41+
@Test
42+
public void testExtractTypedCollectionOfSuperTypes() throws Exception
43+
{
44+
Collection<TestSubClass> testCollection = new HashSet<TypedCollectionUtilitiesTest.TestSubClass>();
45+
testCollection.add(new TestSubClass());
46+
testCollection.add(new TestSubClass());
47+
testCollection.add(new TestSubClass());
48+
testCollection.add(new TestSubSubClass());
49+
testCollection.add(new TestSubSubClass());
50+
51+
assertThat(TypedCollectionUtilities.extractTypedCollection(testCollection, TestClass.class), hasSize(5));
52+
assertThat(TypedCollectionUtilities.extractTypedCollection(testCollection, Object.class), hasSize(5));
3653
}
3754

3855
private static class TestClass

0 commit comments

Comments
 (0)
0