Skip to content
Open
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,22 @@ class CollectionWithDefaultValuesArguments {

}

// Should be able to use null to reset a list (with no ranges specified) to empty
@Test
public void testResetListToNull() {
class ResetListToNull {
@Argument
public List<String> LIST = makeList("foo", "bar");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will use instead a numeric list to check that this is correct. That was one of my bugs (see #41) and maybe it is better to be sure that it is not broken also for collections.

}
final ResetListToNull o = new ResetListToNull();
final CommandLineArgumentParser clp = new CommandLineArgumentParser(o);
final String[] args = {"--LIST","null"};
Assert.assertTrue(clp.parseArguments(System.err, args));
Assert.assertTrue(o.LIST.isEmpty());
}

// Can't use null to reset a list if there are also other values specified (other values automatically
// reset the list).
@Test(expectedExceptions = CommandLineException.class)
public void testClearDefaultValuesFromListArgumentAndAddNew() {
final CollectionWithDefaultValuesArguments o = new CollectionWithDefaultValuesArguments();
Expand All @@ -543,6 +559,7 @@ public void testClearDefaultValuesFromListArgumentAndAddNew() {
Assert.assertEquals(o.LIST, makeList("baz", "frob"));
}

// Replace the initial values in a list with new values
@Test
public void testReplaceListArgument() {
final CollectionWithDefaultValuesArguments o = new CollectionWithDefaultValuesArguments();
Expand Down