Skip to content

Commit

Permalink
Merge branch 'char-array' of https://github.com/triceo/picocli into t…
Browse files Browse the repository at this point in the history
…riceo-char-array
  • Loading branch information
remkop committed Oct 16, 2022
2 parents 6099704 + 0d99a8a commit a0b6d67
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/java/picocli/TypeConversionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static class SupportedTypes {
@Option(names = "-Byte") Byte aByteField;
@Option(names = "-char") char charField;
@Option(names = "-Character") Character aCharacterField;
@Option(names = "-charArray") char[] charArrayField;
@Option(names = "-short") short shortField;
@Option(names = "-Short") Short aShortField;
@Option(names = "-int") int intField;
Expand Down Expand Up @@ -484,6 +485,16 @@ public void testCharConverterInvalidError() throws ParseException {
}
}
@Test
public void testCharArrayConverter() {
try {
final SupportedTypes cli = new SupportedTypes();
CommandLine.populateCommand(new SupportedTypes(), "-charArray", "abcd");
assertEquals(new char[]{'a', 'b', 'c', 'd'}, cli.charArrayField);
} catch (Exception exception) {
fail("Unexpected exception while converting char[] type: " + exception.getMessage());
}
}
@Test
public void testNumberConvertersInvalidError() {
parseInvalidValue("-Byte", "aa", "Invalid value for option '-Byte': 'aa' is not a byte");
parseInvalidValue("-byte", "aa", "Invalid value for option '-byte': 'aa' is not a byte");
Expand Down

0 comments on commit a0b6d67

Please sign in to comment.