The CommandLine class didn't construct command lines with empty arguments correctly (these need to be passed as empty quotes to be recognizable as an argument), fixed; added unit tests that exposes this bug; some minor cosmetic fixes

git-svn-id: file:///srv/devel/repo-conversion/nusu@154 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-06-24 19:20:26 +00:00
parent ce9a6bc932
commit 839d46ecf1
6 changed files with 100 additions and 28 deletions

View file

@ -584,7 +584,7 @@ namespace Nuclex.Support.Parsing {
/// </summary>
[Test]
public void TestCommandLineFormatting() {
CommandLine commandLine = new CommandLine();
CommandLine commandLine = new CommandLine(true);
commandLine.AddValue("single");
commandLine.AddValue("with space");
@ -623,6 +623,23 @@ namespace Nuclex.Support.Parsing {
}
/// <summary>
/// Tests whether a command line can be built that contains empty arguments
/// </summary>
[Test]
public void TestNullArgumentFormatting() {
CommandLine commandLine = new CommandLine(false);
commandLine.AddValue(string.Empty);
commandLine.AddValue("hello");
commandLine.AddValue(null);
commandLine.AddValue("-test");
Assert.AreEqual(4, commandLine.Arguments.Count);
string commandLineString = commandLine.ToString();
Assert.AreEqual("\"\" hello \"\" \"-test\"", commandLineString);
}
}
} // namespace Nuclex.Support.Parsing