示例#1
0
        public void DecimalFractionDigitTest()
        {
            var v = Json5.Parse("1.23");
            var n = (double)v;

            Assert.AreEqual(1.23D, n);
        }
示例#2
0
        public void FalseTest()
        {
            var v = Json5.Parse("false");
            var b = (bool)v;

            Assert.IsFalse(b);
        }
示例#3
0
        public void EmptyTest()
        {
            var v = Json5.Parse("{}");
            var o = (Json5Object)v;

            Assert.AreEqual(0, o.Count);
        }
示例#4
0
        public void ModifiesPropertyValuesTest()
        {
            var val = Json5.Parse("{a:1,b:2}", (k, v) => (k == "a") ? "revived" : v);

            Assert.AreEqual("revived", (string)val["a"]);
            Assert.AreEqual(2D, (double)val["b"]);
        }
示例#5
0
        public void SingleLineCommentsTest()
        {
            var v = Json5.Parse("{//comment\n}");
            var o = (Json5Object)v;

            Assert.AreEqual(0, o.Count);
        }
示例#6
0
        public void LeadingDecimalPointsTest()
        {
            var v = Json5.Parse("[.1,.23]");

            Assert.AreEqual(0.1D, (double)v[0]);
            Assert.AreEqual(0.23D, (double)v[1]);
        }
示例#7
0
        public void InfinityTest()
        {
            var v = Json5.Parse("[Infinity,-Infinity]");

            Assert.AreEqual(double.PositiveInfinity, (double)v[0]);
            Assert.AreEqual(double.NegativeInfinity, (double)v[1]);
        }
示例#8
0
        public void DecimalPointLeadingTest()
        {
            var v = Json5.Parse(".1");
            var n = (double)v;

            Assert.AreEqual(.1D, n);
        }
示例#9
0
        public void WhitespaceTest()
        {
            var v = Json5.Parse("{\t\v\f \u00A0\uFEFF\n\r\u2028\u2029\u2003}");
            var o = (Json5Object)v;

            Assert.AreEqual(0, o.Count);
        }
示例#10
0
        public void DecimalIntegerDigitTest()
        {
            var v = Json5.Parse("12");
            var n = (double)v;

            Assert.AreEqual(12D, n);
        }
示例#11
0
        public void ZeroTest()
        {
            var v = Json5.Parse("0");
            var n = (double)v;

            Assert.AreEqual(0D, n);
        }
示例#12
0
        public void ZeroHexTest()
        {
            var v = Json5.Parse("0x1");
            var n = (double)v;

            Assert.AreEqual(1D, n);
        }
示例#13
0
        public void ZeroDotDigitTest()
        {
            var v = Json5.Parse("0.1");
            var n = (double)v;

            Assert.AreEqual(0.1D, n);
        }
示例#14
0
        public void HexadecimalIntegerTest()
        {
            var v = Json5.Parse("0x12");
            var n = (double)v;

            Assert.AreEqual(0x12, n);
        }
示例#15
0
        public void NonEscapeCharactersTest()
        {
            var v = Json5.Parse(@"'\a\c\d\e'");
            var s = (string)v;

            Assert.AreEqual("acde", s);
        }
示例#16
0
        public void SingleQuoteWithDoubleQuoteTest()
        {
            var v = Json5.Parse("'\"'");
            var s = (string)v;

            Assert.AreEqual("\"", s);
        }
示例#17
0
        public void NestedQuotesInStringsTest()
        {
            var v = Json5.Parse("['\"',\"'\"]");

            Assert.AreEqual("\"", (string)v[0]);
            Assert.AreEqual("'", (string)v[1]);
        }
示例#18
0
        public void AllowUnicodeSeparatorsTest()
        {
            var v = Json5.Parse("'\u2028\u2029'");
            var s = (string)v;

            Assert.AreEqual("\u2028\u2029", s);
        }
示例#19
0
        public void FractionalNumbersTest()
        {
            var v = Json5.Parse("[1.0,1.23]");

            Assert.AreEqual(1D, (double)v[0]);
            Assert.AreEqual(1.23D, (double)v[1]);
        }
示例#20
0
        public void SimpleEscapesTest()
        {
            var v = Json5.Parse(@"'\b\f\n\r\t\v\0'");
            var s = (string)v;

            Assert.AreEqual("\b\f\n\r\t\v\0", s);
        }
示例#21
0
        public void NaNTest()
        {
            var v = Json5.Parse("[NaN,-NaN]");

            Assert.AreEqual(double.NaN, (double)v[0]);
            Assert.AreEqual(double.NaN, (double)v[1]);
        }
示例#22
0
        public void CharacterEscapeTest()
        {
            var v = Json5.Parse(@"'\x12'");
            var s = (string)v;

            Assert.AreEqual("\x12", s);
        }
示例#23
0
        public void MultiLineComments()
        {
            var v = Json5.Parse("{/*comment\n** */}");
            var o = (Json5Object)v;

            Assert.AreEqual(0, o.Count);
        }
示例#24
0
        public void UnicodeEscapeTest()
        {
            var v = Json5.Parse(@"'\u1234'");
            var s = (string)v;

            Assert.AreEqual("\u1234", s);
        }
示例#25
0
        public void EmptyTest()
        {
            var v = Json5.Parse("[]");
            var a = (Json5Array)v;

            Assert.AreEqual(0, a.Count);
        }
示例#26
0
        public void EscapedNewLines()
        {
            var v = Json5.Parse("'\\\n\\\r\\\r\n'");
            var s = (string)v;

            Assert.AreEqual("", s);
        }
示例#27
0
        public void TrueTest()
        {
            var v = Json5.Parse("true");
            var b = (bool)v;

            Assert.IsTrue(b);
        }
示例#28
0
        public void DoubleQuoteEmptyTest()
        {
            var v = Json5.Parse("\"\"");
            var s = (string)v;

            Assert.AreEqual("", s);
        }
示例#29
0
        public void DecimalPointDigitTest()
        {
            var v = Json5.Parse("1.2");
            var n = (double)v;

            Assert.AreEqual(1.2D, n);
        }
示例#30
0
        public void DuplicateKeyTest()
        {
            var v = Json5.Parse("{abc: 0, abc: 1}");
            var o = (Json5Object)v;

            Assert.AreEqual(1, o.Count);
            Assert.AreEqual(1D, (double)o["abc"]);
        }