Example #1
0
 public void ParserGroupsQuotedArguments()
 {
     // feature enable "a b cdef"
     // => feature
     // => enable
     // => a b cdef
     var result = new CommandParser().Parse("feature enable \"a b cdef\"").ToList();
     Assert.NotNull(result);
     Assert.Equal(3, result.Count);
     Assert.Equal("feature", result[0]);
     Assert.Equal("enable", result[1]);
     Assert.Equal("a b cdef", result[2]);
 }
Example #2
0
 public void ParserUnderstandsQuotesInsideArgument()
 {
     // feature enable /foo:"a b cdef"
     // => feature
     // => enable
     // => /foo:a b cdef
     var result = new CommandParser().Parse("feature enable /foo:\"a b cdef\"").ToList();
     Assert.NotNull(result);
     Assert.Equal(3, result.Count);
     Assert.Equal("feature", result[0]);
     Assert.Equal("enable", result[1]);
     Assert.Equal("/foo:a b cdef", result[2]);
 }
Example #3
0
 public void ParserIgnoresExtraSpaces()
 {
     //  a    b    cdef
     // => a
     // => b
     // => cdef
     var result = new CommandParser().Parse("  a    b    cdef   ").ToList();
     Assert.NotNull(result);
     Assert.Equal(3, result.Count);
     Assert.Equal("a", result[0]);
     Assert.Equal("b", result[1]);
     Assert.Equal("cdef", result[2]);
 }
Example #4
0
 public void ParserUnderstandsSimpleArguments()
 {
     // a b cdef
     // => a
     // => b
     // => cdef
     var result = new CommandParser().Parse("a b cdef").ToList();
     Assert.NotNull(result);
     Assert.Equal(3, result.Count);
     Assert.Equal("a", result[0]);
     Assert.Equal("b", result[1]);
     Assert.Equal("cdef", result[2]);
 }
Example #5
0
 public void ParserBackslashEscapesQuote()
 {
     // feature enable \"a b cdef\"
     // => feature
     // => enable
     // => "a
     // => b
     // => cdef"
     var result = new CommandParser().Parse("feature enable \\\"a b cdef\\\"").ToList();
     Assert.NotNull(result);
     Assert.Equal(5, result.Count);
     Assert.Equal("feature", result[0]);
     Assert.Equal("enable", result[1]);
     Assert.Equal("\"a", result[2]);
     Assert.Equal("b", result[3]);
     Assert.Equal("cdef\"", result[4]);
 }
Example #6
0
 public void ParserBackslashDoesnotEscapeBackslash()
 {
     // feature enable \\a
     // => feature
     // => enable
     // => \\a
     var result = new CommandParser().Parse("feature enable \\\\a").ToList();
     Assert.NotNull(result);
     Assert.Equal(3, result.Count);
     Assert.Equal("feature", result[0]);
     Assert.Equal("enable", result[1]);
     Assert.Equal("\\\\a", result[2]);
 }
Example #7
0
 public void ParserUnderstandsEmptyArgument3()
 {
     // ""
     // => <empty arg>
     var result = new CommandParser().Parse("\"\"").ToList();
     Assert.NotNull(result);
     Assert.Equal(1, result.Count);
     Assert.Equal("", result[0]);
 }
Example #8
0
 public void ParserUnderstandsTrailingQuote()
 {
     // feature enable "
     // => feature
     // => enable
     // => <empty arg>
     var result = new CommandParser().Parse("feature enable \"").ToList();
     Assert.NotNull(result);
     Assert.Equal(3, result.Count);
     Assert.Equal("feature", result[0]);
     Assert.Equal("enable", result[1]);
     Assert.Equal("", result[2]);
 }
Example #9
0
 public void ParserUnderstandsTrailingBackslash2()
 {
     // feature enable b\
     // => feature
     // => enable
     // => b\
     var result = new CommandParser().Parse("feature enable b\\").ToList();
     Assert.NotNull(result);
     Assert.Equal(3, result.Count);
     Assert.Equal("feature", result[0]);
     Assert.Equal("enable", result[1]);
     Assert.Equal("b\\", result[2]);
 }