mirror of
https://github.com/gbevin/urlencoder.git
synced 2025-04-25 07:17:11 -07:00
Handle more invalid CLI argument usages.
This commit is contained in:
parent
ca82b1ec6d
commit
97bc6137a3
2 changed files with 16 additions and 2 deletions
|
@ -237,9 +237,9 @@ public final class UrlEncoder {
|
|||
var option = args.remove(0);
|
||||
if (option.equals("-d")) {
|
||||
perform_decode = true;
|
||||
valid_arguments = !args.isEmpty();
|
||||
valid_arguments = (args.size() == 1);
|
||||
} else if (option.equals("-e")) {
|
||||
valid_arguments = !args.isEmpty();
|
||||
valid_arguments = (args.size() == 1);
|
||||
} else {
|
||||
args.clear();
|
||||
}
|
||||
|
|
|
@ -94,6 +94,20 @@ class UrlEncoderTest {
|
|||
assertTrue(result.output.contains("Usage :"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMainWrongArgs4() {
|
||||
var result = UrlEncoder.processMain(new String[] {"-d", "stuff", "txt"});
|
||||
assertEquals(1, result.status);
|
||||
assertTrue(result.output.contains("Usage :"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMainWrongArgs5() {
|
||||
var result = UrlEncoder.processMain(new String[] {"-e", "stuff", "txt"});
|
||||
assertEquals(1, result.status);
|
||||
assertTrue(result.output.contains("Usage :"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDecodeMainOption() {
|
||||
validMap.forEach((expected, source) -> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue