Пример #1
0
        private void AssertStringParsed(string prefix, string postfix, string quoted, string expected)
        {
            var str = $"'{quoted}'";

            var(parsed, end) = QuotationReader.ReadQuotation(
                prefix + str + postfix, prefix.Length);

            Assert.AreEqual(expected, parsed);
            Assert.AreEqual(str.Length - 1 + prefix.Length, end);
        }
Пример #2
0
        public void TextIsNotCorrect_ErrorIntervalAsExpected(string before, string error, string after)
        {
            var prefix = "some prefix ";
            var str    = prefix + before + error + after;
            var ex     = Assert.Throws <FunParseException>(() =>
                                                           QuotationReader.ReadQuotation(str, prefix.Length));

            Console.WriteLine("Origin string to parse: " + str);
            Console.WriteLine("Parse error: [FU" + ex.Code + "] " + ex.Message);
            var foundError = ex.Interval.SubString(str);

            Console.WriteLine($"Catched error string: \"{foundError}\"");
            Assert.AreEqual(error, foundError);
        }
Пример #3
0
 public void CloseQuoteMissing_returnsNegativeOne(string text)
 {
     var(result, resultPosition) = QuotationReader.ReadQuotation(text, 0);
     Assert.AreEqual(-1, resultPosition);
 }