Skip to content

Commit

Permalink
#571 add Interpreter.canConsumeOneMapArgument test
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Jan 2, 2019
1 parent 633e40a commit 6586048
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/test/java/picocli/CommandLineTypeConversionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.junit.contrib.java.lang.system.SystemErrRule;
import org.junit.rules.TestRule;
import picocli.CommandLine.ITypeConverter;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import picocli.CommandLine.TypeConversionException;
import picocli.CommandLine.*;

import static java.util.concurrent.TimeUnit.*;
import static org.junit.Assert.*;
Expand Down Expand Up @@ -1035,6 +1032,30 @@ class App {
@Parameters(converter = SplitSemiColonConverter.class) String[] all;
}
App app = CommandLine.populateCommand(new App(), "a;b;c", "1;2;3");
assertEquals(new String[] {"a", "b", "c", "1", "2", "3"}, app.all);
assertArrayEquals(new String[] {"a", "b", "c", "1", "2", "3"}, app.all);
}

@Test
public void testMapArgumentsMustContainEquals() {
class App {
@Parameters Map<String, String> map;
}
try {
CommandLine.populateCommand(new App(), "a:c", "1:3");
} catch (UnmatchedArgumentException ex) {
assertEquals("Unmatched arguments: a:c, 1:3", ex.getMessage());
}
}

@Test
public void testMapArgumentsMustContainEquals2() {
class App {
@Parameters(split = "==") Map<String, String> map;
}
try {
CommandLine.populateCommand(new App(), "a:c", "1:3");
} catch (UnmatchedArgumentException ex) {
assertEquals("Unmatched arguments: a:c, 1:3", ex.getMessage());
}
}
}

0 comments on commit 6586048

Please sign in to comment.