Skip to content

Commit 1f6b17d

Browse files
committed
Added test to validate that Convert.fromString works with enums
1 parent 917bf95 commit 1f6b17d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/test/java/rife/tools/TestConvert.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ public static MyCustomType fromString(String v) {
172172
}
173173
}
174174

175+
public enum Action {
176+
none, add, modify, cancel
177+
}
178+
175179
@Test
176180
void testFromString()
177181
throws ConversionException {
@@ -191,6 +195,9 @@ void testFromString()
191195
assertThrows(ConversionException.class, () -> Convert.fromString("invalid", MyCustomType.class));
192196

193197
assertThrows(ConversionException.class, () -> Convert.fromString("custom", MyCustomType2.class));
198+
199+
assertEquals(Action.add, Convert.fromString("add", Action.class));
200+
assertThrows(ConversionException.class, () -> Convert.fromString("nothing", Action.class));
194201
}
195202

196203
@Test

0 commit comments

Comments
 (0)