Skip to content

Commit

Permalink
Improved VariableArityTest: Proofs that unknown options are safely pa…
Browse files Browse the repository at this point in the history
…ssed through
  • Loading branch information
mkarg committed Oct 7, 2023
1 parent 5902f52 commit aeec36f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/test/java/com/beust/jcommander/VariableArityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public static class ModelGenerationConfig {
@Parameter(names = { "--seed" }, description = "Seed used for PRNG [0 means don't use a Seed]")
public long seed = 0;

@Parameter(names = "-J", description = "Parameters to be passed to child process", variableArity = true)
public List<String> j;

public void print() {
System.out.println("modelMatrixFile: " + modelMatrixFile);
System.out.println("featureData: " + featureFile);
Expand All @@ -42,7 +45,7 @@ public void print() {

@Test
public void verifyVariableArity() {
String input = "-m foo --seed 1024 -c foo -o foo -f foo ";
String input = "-m foo --seed 1024 -J --compilation_level WHITESPACE_ONLY --language_in=ECMASCRIPT5 -bar baz -faz -c foo -o foo -f foo -J --more-options";

String[] split = input.split("\\s+");

Expand All @@ -56,7 +59,9 @@ public void verifyVariableArity() {
Assert.assertEquals(config.modelMatrixFile, Arrays.asList("foo"));
Assert.assertEquals(config.featureFile, Arrays.asList("foo"));
Assert.assertEquals(config.seed, 1024);
Assert.assertEquals(config.configFile, Arrays.asList("foo"));
Assert.assertEquals(config.outputFile, "foo");
Assert.assertEquals(config.j, Arrays.asList("--compilation_level", "WHITESPACE_ONLY", "--language_in=ECMASCRIPT5", "-bar", "baz", "-faz", "--more-options"));
}

public static void main(String[] args) {
Expand Down

0 comments on commit aeec36f

Please sign in to comment.