コード例 #1
0
        public void Test_String(string token, string expected)
        {
            // Act
            var result = _parser.Parse(token);

            // Assert
            Assert.IsType <ConstantExpression>(result);
            Assert.Equal(expected, (result as ConstantExpression).Value);
        }
コード例 #2
0
        public void BasicTest()
        {
            var parser = new StringTokenParser();

            using (var input = ParserInput.CreateFromString("\"Hello World!\""))
                Assert.Equal("Hello World!", parser.Parse(input));

            using (var input = ParserInput.CreateFromString("\"\\\\\""))
                Assert.Equal("\\", parser.Parse(input));

            parser.EscapedCharLookup.Add('t', '\t');

            using (var input = ParserInput.CreateFromString("\"\\tHello\""))
                Assert.Equal("\tHello", parser.Parse(input));
        }
コード例 #3
0
        public void DoubleQuotationTest()
        {
            var doubleQuoteStringParser = new StringTokenParser(true);

            using (var input = ParserInput.CreateFromString("\"abc\"\"123\""))
                Assert.Equal("abc\"123", doubleQuoteStringParser.Parse(input));

            var singleQuoteParser = new StringTokenParser(true, '\'');

            using (var input = ParserInput.CreateFromString("'abc''123'"))
                Assert.Equal("abc'123", singleQuoteParser.Parse(input));
        }