Skip to content

Commit

Permalink
Asserting that double quotes are not removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan de Gorter authored and mkarg committed Dec 21, 2023
1 parent bee2d39 commit 46b12bd
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/java/com/beust/jcommander/TestParameterQuoteHandling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.beust.jcommander;

import java.util.List;

import org.testng.Assert;
import org.testng.annotations.Test;

@Parameters(separators = "=", commandDescription = "Just for testing quote handling.")
public class TestParameterQuoteHandling {

@Parameter(names = { "--aParameter" }, description = "A String.")
public String aParameter = null;

@Parameter(names = { "--aParameterList"}, description = "A String list.")
public List<String> aParameterList = null;

@Test
public void testParameterHavingQuotes() {
JCommander jc = new JCommander(this);
jc.parse("--aParameter=\"X\"");
Assert.assertNotNull(aParameter);
// as of JCommander 1.74/75
Assert.assertEquals(aParameter, "\"X\"", "Expect \"X\" for JCommander 1.74/75 and more recent");
}

@Test
public void testParameterListHavingQuotes() {
JCommander jc = new JCommander(this);
jc.parse("--aParameterList=\"X,Y\"");
Assert.assertNotNull(aParameterList);
Assert.assertEquals(aParameterList.size(), 2);
Assert.assertEquals(aParameterList.get(0), "\"X");
Assert.assertEquals(aParameterList.get(1), "Y\"");
}
}

0 comments on commit 46b12bd

Please sign in to comment.