Wrote more unit tests for the new command line parser; actually implemented a good part of the new command line parser; wrote one more test to show that the old command line parser is broken
git-svn-id: file:///srv/devel/repo-conversion/nusu@106 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
f0d76f988f
commit
ffba112786
4 changed files with 285 additions and 40 deletions
|
@ -31,6 +31,74 @@ namespace Nuclex.Support.Parsing {
|
|||
/// <summary>Ensures that the command line parser is working properly</summary>
|
||||
[TestFixture]
|
||||
public class CommandLineTest {
|
||||
|
||||
/*
|
||||
struct CommandLine {
|
||||
[Option]
|
||||
bool? Option;
|
||||
[Option]
|
||||
int? Width;
|
||||
[Option]
|
||||
TypeCode Code;
|
||||
[Values]
|
||||
string[] Values;
|
||||
}
|
||||
*/
|
||||
/// <summary>Validates that a single argument without quotes can be parsed</summary>
|
||||
[Test]
|
||||
public void TestParseSingleNakedArgument() {
|
||||
CommandLine.Parse("Hello");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates that the parser can handle a single argument initator without
|
||||
/// a following argument
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestParseLoneArgumentInitiator() {
|
||||
CommandLine.Parse("/");
|
||||
CommandLine.Parse("-");
|
||||
CommandLine.Parse("--");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates that the parser can handle multiple lone argument initators without
|
||||
/// a following argument
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestParseMultipleLoneArgumentInitiators() {
|
||||
CommandLine.Parse("/ // /");
|
||||
CommandLine.Parse("- -- -");
|
||||
CommandLine.Parse("-- --- --");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates that the parser can handle multiple lone argument initators without
|
||||
/// a following argument
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestParseArgumentInitiatorsWithInvalidNames() {
|
||||
CommandLine.Parse("/=:");
|
||||
CommandLine.Parse("-/=");
|
||||
CommandLine.Parse("--:/");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates that the parser can handle an command line consisting of only spaces
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestParseSpacesOnly() {
|
||||
CommandLine.Parse(" \t ");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates that the parser can handle a quoted argument that's missing
|
||||
/// the closing quote
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestParseQuoteArgumentWithoutClosingQuote() {
|
||||
CommandLine.Parse("\"Quoted argument");
|
||||
}
|
||||
|
||||
/// <summary>Validates that normal arguments can be parsed</summary>
|
||||
[Test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue