Esempio n. 1
0
        protected IExpectPattern expectsOptionallyQuotedValue()
        {
            var pattern = new OptionallyQuoted();

            pattern.Terminators = Objects.Enumerate(']');
            return(pattern);
        }
Esempio n. 2
0
        public void OptionallyQuoted()
        {
            scanner = @"key[value='this ""is \' a quoted value']";
            StringScannerEngine inner = scanner.ExpectAlpha()
                                        .Get(MatchFunctions.Bounded);

            scanner.AssertFinished();

            inner.Expect(MatchFunctions.HTMLAttribute())
            .Expect("=");

            var optQuote = new OptionallyQuoted();

            optQuote.Terminators = "]";

            string text = inner.Get(optQuote);

            Assert.AreEqual(@"this ""is \' a quoted value", text, "Got the right text");

            inner.Text = @"this ""is \' a quoted value";
            text       = inner.Get(optQuote);
            Assert.AreEqual("this \"is \\' a quoted value", text, "Got the right text without quotes");

            inner.Text = @"""this is \"" a quoted value""";
            text       = inner.Get(optQuote);
            Assert.AreEqual("this is \\\" a quoted value", text, "Got the right text with quotes");
        }