Beispiel #1
0
 public void SpaceTest()
 {
     ExpressionLexer lexer = new SearchLexer("st    dn rd");
     ValidateStringLiteralToken(lexer, "st");
     ValidateStringLiteralToken(lexer, "dn");
     ValidateStringLiteralToken(lexer, "rd");
     ValidateTokenKind(lexer, ExpressionTokenKind.End);
 }
Beispiel #2
0
 public void QuoteAndEscapeTest()
 {
     ExpressionLexer lexer = new SearchLexer("a \"AND \\\"bc\\\\ OR \" def");
     ValidateStringLiteralToken(lexer, "a");
     ValidateStringLiteralToken(lexer, "AND \"bc\\ OR ");
     ValidateStringLiteralToken(lexer, "def");
     ValidateTokenKind(lexer, ExpressionTokenKind.End);
 }
Beispiel #3
0
 public void ContinuousQuoteTest()
 {
     ExpressionLexer lexer = new SearchLexer("a \"AND \\\"bc\\\\ OR \"\"VV\" def");
     ValidateStringLiteralToken(lexer, "a");
     ValidateStringLiteralToken(lexer, "AND \"bc\\ OR ");
     ValidateStringLiteralToken(lexer, "VV");
     ValidateStringLiteralToken(lexer, "def");
     ValidateTokenKind(lexer, ExpressionTokenKind.End);
 }
Beispiel #4
0
 public void TermTest()
 {
     ExpressionLexer lexer = new SearchLexer("a AND bc OR  def");
     ValidateStringLiteralToken(lexer, "a");
     ValidateIdentifierToken(lexer, "AND");
     ValidateStringLiteralToken(lexer, "bc");
     ValidateIdentifierToken(lexer, "OR");
     ValidateStringLiteralToken(lexer, "def");
     ValidateTokenKind(lexer, ExpressionTokenKind.End);
 }
Beispiel #5
0
 public void ParenTest()
 {
     ExpressionLexer lexer = new SearchLexer("st    (dn   rd)");
     ValidateStringLiteralToken(lexer, "st");
     ValidateTokenKind(lexer, ExpressionTokenKind.OpenParen);
     ValidateStringLiteralToken(lexer, "dn");
     ValidateStringLiteralToken(lexer, "rd");
     ValidateTokenKind(lexer, ExpressionTokenKind.CloseParen);
     ValidateTokenKind(lexer, ExpressionTokenKind.End);
 }
Beispiel #6
0
        public void InvalidCharWithOutQuoteTest()
        {
            ExpressionLexer lexer = new SearchLexer("\"b\\\"cd a3\"");
            ValidateStringLiteralToken(lexer, "b\"cd a3");
            ValidateTokenKind(lexer, ExpressionTokenKind.End);
            lexer = new SearchLexer("\"bcd za3\"");
            ValidateStringLiteralToken(lexer, "bcd za3");
            ValidateTokenKind(lexer, ExpressionTokenKind.End);

            Action action = () => new SearchLexer("b\\\"cd a3").NextToken();
            action.ShouldThrow<ODataException>().WithMessage(Strings.ExpressionLexer_InvalidCharacter("\\", 1, "b\\\"cd a3"));
            action = () => new SearchLexer("bcd za3").NextToken();
            action.ShouldThrow<ODataException>().WithMessage(Strings.ExpressionLexer_InvalidCharacter("3", 6, "bcd za3"));
            action = () => new SearchLexer("\" za\"\\").NextToken();
            action.ShouldThrow<ODataException>().WithMessage(Strings.ExpressionLexer_InvalidCharacter("\\", 5, "\" za\"\\"));
        }
Beispiel #7
0
 public void BasicTest()
 {
     ExpressionLexer lexer = new SearchLexer("rd");
     ValidateStringLiteralToken(lexer, "rd");
     ValidateTokenKind(lexer, ExpressionTokenKind.End);
 }
Beispiel #8
0
 public void UnmatchedParenTest()
 {
     ExpressionLexer lexer = new SearchLexer("kit )");
     ValidateStringLiteralToken(lexer, "kit");
     ValidateTokenKind(lexer, ExpressionTokenKind.CloseParen);
     ValidateTokenKind(lexer, ExpressionTokenKind.End);
 }
Beispiel #9
0
 public void EmptyPhraseInputTest()
 {
     ExpressionLexer lexer = new SearchLexer("A \"\"");
     Action action = () => lexer.NextToken();
     action.ShouldThrow<ODataException>().WithMessage(Strings.ExpressionToken_IdentifierExpected((2)));
     action = () => new SearchLexer("\"\" A");
     action.ShouldThrow<ODataException>().WithMessage(Strings.ExpressionToken_IdentifierExpected((0)));
 }
Beispiel #10
0
 public void EmptyInputTest()
 {
     ExpressionLexer lexer = new SearchLexer("");
     ValidateTokenKind(lexer, ExpressionTokenKind.End);
 }