Skip to content

Commit 31c7081

Browse files
committed
Update EnumUtilsTest.java
1 parent 4dfa7ca commit 31c7081

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

  • microsphere-annotation-processor/src/test/java/io/microsphere/annotation/processor/util

microsphere-annotation-processor/src/test/java/io/microsphere/annotation/processor/util/EnumUtilsTest.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525

2626
import static io.microsphere.annotation.processor.util.EnumUtils.matches;
2727
import static io.microsphere.annotation.processor.util.EnumUtils.toElementKind;
28+
import static java.lang.annotation.ElementType.FIELD;
29+
import static java.lang.annotation.ElementType.TYPE;
2830
import static java.lang.annotation.ElementType.values;
31+
import static org.junit.jupiter.api.Assertions.assertFalse;
2932
import static org.junit.jupiter.api.Assertions.assertNotNull;
3033
import static org.junit.jupiter.api.Assertions.assertTrue;
3134

@@ -52,12 +55,34 @@ public void testMatches() {
5255
}
5356
}
5457

58+
@Test
59+
public void testMatchesOnNull() {
60+
assertFalse(matches(null, (ElementType) null));
61+
assertFalse(matches(null, TYPE));
62+
assertFalse(matches(toElementKind(TYPE), (ElementType) null));
63+
}
64+
65+
@Test
66+
public void testMatchesWithArray() {
67+
for (ElementType elementType : values()) {
68+
assertTrue(matches(toElementKind(elementType), values()));
69+
}
70+
}
71+
72+
@Test
73+
public void testMatchesWithArrayOnNull() {
74+
assertFalse(matches(null));
75+
assertFalse(matches(null, (ElementType[]) null));
76+
assertFalse(matches(null, TYPE, FIELD));
77+
assertFalse(matches(toElementKind(TYPE), (ElementType[]) null));
78+
}
79+
5580
void assertElementKind(ElementType elementType) {
5681
ElementKind elementKind = toElementKind(elementType);
5782
assertNotNull(elementKind);
5883
}
5984

6085
void assertMatches(ElementType elementType) {
61-
assertTrue(matches(elementType, toElementKind(elementType)));
86+
assertTrue(matches(toElementKind(elementType), elementType));
6287
}
6388
}

0 commit comments

Comments
 (0)