Exemple #1
0
        public void IgnoresStandaloneTripleAt()
        {
            var result = TextCommandWordParser.Parse("This is @@@ example").ToArray();

            Assert.AreEqual(3, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.AreEqual("is", result[1].Value);
            Assert.AreEqual("example", result[2].Value);
        }
Exemple #2
0
        public void UseAtInNonParameter()
        {
            var result = TextCommandWordParser.Parse("This is a@n example").ToArray();

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.AreEqual("is", result[1].Value);
            Assert.AreEqual("a@n", result[2].Value);
            Assert.AreEqual("example", result[3].Value);
        }
Exemple #3
0
        public void UseAtInEndOfWord()
        {
            var result = TextCommandWordParser.Parse("This is an@ example").ToArray();

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.AreEqual("is", result[1].Value);
            Assert.AreEqual("an@", result[2].Value);
            Assert.AreEqual("example", result[3].Value);
        }
Exemple #4
0
        public void UnderstandEscapedSingleQuoteInsideSingleQuoteContext()
        {
            var result = TextCommandWordParser.Parse(@"This 'is \' \n@' 'a\'n@' @example").ToArray();

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.AreEqual("is ' \n@", result[1].Value);
            Assert.AreEqual("a'n@", result[2].Value);
            Assert.AreEqual("example", result[3].Value);
        }
Exemple #5
0
        public void EscapeAt()
        {
            var result = TextCommandWordParser.Parse("This is \\@an example").ToArray();

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.AreEqual("is", result[1].Value);
            Assert.AreEqual("@an", result[2].Value);
            Assert.AreEqual("example", result[3].Value);
        }
Exemple #6
0
        public void UnderstandSingleQuoteInsideDoubleQuoteContext()
        {
            var result = TextCommandWordParser.Parse("This \"is ' \n@\" \"an'@\" @example").ToArray();

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.AreEqual("is ' \n@", result[1].Value);
            Assert.AreEqual("an'@", result[2].Value);
            Assert.AreEqual("example", result[3].Value);
        }
Exemple #7
0
        public void UnderstandQuoteContext()
        {
            var result = TextCommandWordParser.Parse("This 'is \n@' 'an@' @example").ToArray();

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.AreEqual("is \n@", result[1].Value);
            Assert.AreEqual("an@", result[2].Value);
            Assert.AreEqual("example", result[3].Value);
        }
Exemple #8
0
        public void SimpleParsingWithEscapedChars()
        {
            var result = TextCommandWordParser.Parse("This\t\tis\ran\r\nexample").ToArray();

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.IsFalse(result[0].IsEndOfLine);
            Assert.AreEqual("is", result[1].Value);
            Assert.IsTrue(result[1].IsEndOfLine);
            Assert.AreEqual("an", result[2].Value);
            Assert.IsTrue(result[2].IsEndOfLine);
            Assert.AreEqual("example", result[3].Value);
            Assert.IsTrue(result[3].IsEndOfLine);
        }
Exemple #9
0
        public void ParameterParsing()
        {
            var result = TextCommandWordParser.Parse("This @is an @example").ToArray();

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.IsFalse(result[0].IsParameter);
            Assert.AreEqual("is", result[1].Value);
            Assert.IsTrue(result[1].IsParameter);
            Assert.AreEqual("an", result[2].Value);
            Assert.IsFalse(result[2].IsParameter);
            Assert.AreEqual("example", result[3].Value);
            Assert.IsTrue(result[3].IsParameter);
        }
Exemple #10
0
        public void ContinueSkippingSpaces()
        {
            var result = TextCommandWordParser.Parse("This @is\t\rtesting.").ToArray();

            Assert.AreEqual(3, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.IsFalse(result[0].IsParameter);
            Assert.IsFalse(result[0].IsEndOfLine);

            Assert.AreEqual("is", result[1].Value);
            Assert.IsTrue(result[1].IsParameter);
            Assert.IsTrue(result[1].IsEndOfLine);

            Assert.AreEqual("testing.", result[2].Value);
            Assert.IsFalse(result[2].IsParameter);
            Assert.IsTrue(result[2].IsEndOfLine);
        }
Exemple #11
0
        public void ParametersParsingAndSpecialChars()
        {
            var result = TextCommandWordParser.Parse("This @is\t\ran\t@@example\r\n").ToArray();

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("This", result[0].Value);
            Assert.IsFalse(result[0].IsParameter);
            Assert.IsFalse(result[0].IsEndOfLine);

            Assert.AreEqual("is", result[1].Value);
            Assert.IsTrue(result[1].IsParameter);
            Assert.IsTrue(result[1].IsEndOfLine);

            Assert.AreEqual("an", result[2].Value);
            Assert.IsFalse(result[2].IsParameter);
            Assert.IsFalse(result[2].IsEndOfLine);

            Assert.AreEqual("example", result[3].Value);
            Assert.IsTrue(result[3].IsParameter);
            Assert.IsTrue(result[3].IsEndOfLine);
        }