Skip to content

Commit

Permalink
remkop#441: added minimal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bbottema committed Aug 15, 2018
1 parent 826fb72 commit 0ab7e96
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/test/java/picocli/CommandLineModelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ public void testModelUsageHelp() throws Exception {
spec.addOption(OptionSpec.builder("-h", "--help").usageHelp(true).description("show help and exit").build());
spec.addOption(OptionSpec.builder("-V", "--version").versionHelp(true).description("show help and exit").build());
spec.addOption(OptionSpec.builder("-c", "--count").paramLabel("COUNT").arity("1").type(int.class).description("number of times to execute").build());
spec.addOption(OptionSpec.builder("-f", "--fix").paramLabel("FIXED(=BOOLEAN)").arity("1").fixParamLabel(true).required(true).description("run with fixed option").build());
CommandLine commandLine = new CommandLine(spec);
String actual = usageString(commandLine, Ansi.OFF);
String expected = String.format("" +
"Usage: <main class> [-hV] [-c=COUNT]%n" +
"Usage: <main class> [-hV] [-c=COUNT] -f FIXED(=BOOLEAN)%n" +
" -c, --count=COUNT number of times to execute%n" +
" -f, --fix FIXED(=BOOLEAN)%n" +
" run with fixed option%n" +
" -h, --help show help and exit%n" +
" -V, --version show help and exit%n");
assertEquals(expected, actual);
Expand Down Expand Up @@ -494,6 +497,10 @@ public void testOptionDefaultRequiredIsFalse() throws Exception {
public void testPositionalDefaultRequiredIsFalse() throws Exception {
assertFalse(PositionalParamSpec.builder().build().required());
}
@Test
public void testPositionalDefaultFixParamLabelIsFalse() throws Exception {
assertFalse(PositionalParamSpec.builder().build().fixParamLabel());
}

@Test
public void testOptionDefaultTypeIsBoolean_withDefaultArity() throws Exception {
Expand Down

0 comments on commit 0ab7e96

Please sign in to comment.