Skip to content

Commit

Permalink
Add test for Option.toString
Browse files Browse the repository at this point in the history
  • Loading branch information
lacinoire authored and igr committed Jun 22, 2022
1 parent f039c71 commit 6478983
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions jodd-core/src/test/java/jodd/cli/CliOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package jodd.cli;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
Expand Down Expand Up @@ -132,4 +133,18 @@ void testOptionWithValue() {
assertEquals("[1, F]", out.toString());
out.clear();
}

@Test
void testToString() throws Exception {
final List<String> out = new ArrayList<>();
final Cli cli = new Cli();
cli.option().shortName("a").hasArg().with(out::add);
cli.option().longName("foo").hasArg().with(out::add);
cli.printUsage("cmd");
cli.accept("-a", "1", "--foo", "F");
out.clear();
cli.accept("-a=1", "--foo=F");
out.clear();
Assertions.assertEquals("--foo", cli.option().longName("foo").hasArg().with(out::add).toString());
}
}

0 comments on commit 6478983

Please sign in to comment.