-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Asserting that double quotes are not removed.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/test/java/com/beust/jcommander/TestParameterQuoteHandling.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\""); | ||
} | ||
} |