Beispiel #1
0
        public void EscapeValidString()
        {
            string validEscapeString = "\\b\\n\\f\\r\\t\\\"\\\\";

            string result = ParserUtils.EscapeString(validEscapeString);

            Assert.AreEqual("\b\n\f\r\t\"\\", result);
        }
Beispiel #2
0
        public void EscapeInvalidUnicode()
        {
            string invalidUnicodeString = "\\uasd";

            Assert.Throws <FormatException>(() => ParserUtils.EscapeString(invalidUnicodeString));

            invalidUnicodeString = "\\uGgGg";

            Assert.Throws <FormatException>(() => ParserUtils.EscapeString(invalidUnicodeString));
        }
Beispiel #3
0
        public void EscapeInvalidString()
        {
            string invalidEscapeString = "\\a\\c\\e\t\\\\r'";

            Assert.Throws <FormatException>(() => ParserUtils.EscapeString(invalidEscapeString));

            invalidEscapeString = "\\asdf";

            Assert.Throws <FormatException>(() => ParserUtils.EscapeString(invalidEscapeString));
        }
Beispiel #4
0
        void value(out SKONObject skonObject)
        {
            skonObject = null;
            switch (la.kind)
            {
            case 12: {
                Get();
                skonObject = new SKONObject(ParserUtils.EscapeString(t.val.Substring(1, t.val.Length - 2)));
                break;
            }

            case 14: {
                Get();
                skonObject = new SKONObject(int.Parse(t.val));
                break;
            }

            case 15: {
                Get();
                skonObject = new SKONObject(double.Parse(t.val, CultureInfo.InvariantCulture));
                break;
            }

            case 16: {
                Get();
                skonObject = new SKONObject(ParseDatetime(t.val));
                break;
            }

            case 4: {
                skon_map(out skonObject);
                break;
            }

            case 6: {
                skon_array(out skonObject);
                break;
            }

            case 17: {
                Get();
                skonObject = new SKONObject(true);
                break;
            }

            case 18: {
                Get();
                skonObject = new SKONObject(false);
                break;
            }

            default: SynErr(20); break;
            }
        }
Beispiel #5
0
 void meta_SKEMA(out string skema)
 {
     Expect(11);
     Expect(2);
     Expect(12);
     if (t.val.Length > 2)
     {
         skema = ParserUtils.EscapeString(t.val.Substring(1, t.val.Length - 2));
     }
     else
     {
         skema = "INVALID";
     }
     Expect(1);
 }
Beispiel #6
0
 void meta_docVersion(out string ver)
 {
     Expect(10);
     Expect(2);
     Expect(12);
     if (t.val.Length > 2)
     {
         ver = ParserUtils.EscapeString(t.val.Substring(1, t.val.Length - 2));
     }
     else
     {
         ver = "INVALID";
     }
     Expect(1);
 }
Beispiel #7
0
        public void EscapeValidUnicode()
        {
            string validUnicodeString = "\\u00D6";

            string result = ParserUtils.EscapeString(validUnicodeString);

            Assert.AreEqual("\u00D6", result);

            validUnicodeString = "\\uFEFF\\uFFFE";

            result = ParserUtils.EscapeString(validUnicodeString);

            Assert.AreEqual("\uFEFF\uFFFE", result);

            validUnicodeString = string.Empty;

            result = ParserUtils.EscapeString(validUnicodeString);

            Assert.AreEqual(string.Empty, ParserUtils.EscapeString(validUnicodeString));
        }
Beispiel #8
0
        public void EscapeLongString()
        {
            string longString = new string('A', 10000000);

            string result = ParserUtils.EscapeString(longString);

            Assert.AreEqual(longString, result);

            int escapeInserts = 5000000;

            StringBuilder longStringBuilder = new StringBuilder(escapeInserts * 2);

            for (int i = 0; i < escapeInserts; i++)
            {
                longStringBuilder.Append("\t");
            }

            longString = longStringBuilder.ToString();

            result = ParserUtils.EscapeString(longString);

            Assert.AreEqual(longString, result);
        }