Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a failing test for char[] type conversion #648

Merged
merged 1 commit into from
Oct 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/test/java/picocli/CommandLineTypeConversionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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 @@ -496,6 +497,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