public void DecimalFractionDigitTest() { var v = Json5.Parse("1.23"); var n = (double)v; Assert.AreEqual(1.23D, n); }
public void FalseTest() { var v = Json5.Parse("false"); var b = (bool)v; Assert.IsFalse(b); }
public void EmptyTest() { var v = Json5.Parse("{}"); var o = (Json5Object)v; Assert.AreEqual(0, o.Count); }
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"]); }
public void SingleLineCommentsTest() { var v = Json5.Parse("{//comment\n}"); var o = (Json5Object)v; Assert.AreEqual(0, o.Count); }
public void LeadingDecimalPointsTest() { var v = Json5.Parse("[.1,.23]"); Assert.AreEqual(0.1D, (double)v[0]); Assert.AreEqual(0.23D, (double)v[1]); }
public void InfinityTest() { var v = Json5.Parse("[Infinity,-Infinity]"); Assert.AreEqual(double.PositiveInfinity, (double)v[0]); Assert.AreEqual(double.NegativeInfinity, (double)v[1]); }
public void DecimalPointLeadingTest() { var v = Json5.Parse(".1"); var n = (double)v; Assert.AreEqual(.1D, n); }
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); }
public void DecimalIntegerDigitTest() { var v = Json5.Parse("12"); var n = (double)v; Assert.AreEqual(12D, n); }
public void ZeroTest() { var v = Json5.Parse("0"); var n = (double)v; Assert.AreEqual(0D, n); }
public void ZeroHexTest() { var v = Json5.Parse("0x1"); var n = (double)v; Assert.AreEqual(1D, n); }
public void ZeroDotDigitTest() { var v = Json5.Parse("0.1"); var n = (double)v; Assert.AreEqual(0.1D, n); }
public void HexadecimalIntegerTest() { var v = Json5.Parse("0x12"); var n = (double)v; Assert.AreEqual(0x12, n); }
public void NonEscapeCharactersTest() { var v = Json5.Parse(@"'\a\c\d\e'"); var s = (string)v; Assert.AreEqual("acde", s); }
public void SingleQuoteWithDoubleQuoteTest() { var v = Json5.Parse("'\"'"); var s = (string)v; Assert.AreEqual("\"", s); }
public void NestedQuotesInStringsTest() { var v = Json5.Parse("['\"',\"'\"]"); Assert.AreEqual("\"", (string)v[0]); Assert.AreEqual("'", (string)v[1]); }
public void AllowUnicodeSeparatorsTest() { var v = Json5.Parse("'\u2028\u2029'"); var s = (string)v; Assert.AreEqual("\u2028\u2029", s); }
public void FractionalNumbersTest() { var v = Json5.Parse("[1.0,1.23]"); Assert.AreEqual(1D, (double)v[0]); Assert.AreEqual(1.23D, (double)v[1]); }
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); }
public void NaNTest() { var v = Json5.Parse("[NaN,-NaN]"); Assert.AreEqual(double.NaN, (double)v[0]); Assert.AreEqual(double.NaN, (double)v[1]); }
public void CharacterEscapeTest() { var v = Json5.Parse(@"'\x12'"); var s = (string)v; Assert.AreEqual("\x12", s); }
public void MultiLineComments() { var v = Json5.Parse("{/*comment\n** */}"); var o = (Json5Object)v; Assert.AreEqual(0, o.Count); }
public void UnicodeEscapeTest() { var v = Json5.Parse(@"'\u1234'"); var s = (string)v; Assert.AreEqual("\u1234", s); }
public void EmptyTest() { var v = Json5.Parse("[]"); var a = (Json5Array)v; Assert.AreEqual(0, a.Count); }
public void EscapedNewLines() { var v = Json5.Parse("'\\\n\\\r\\\r\n'"); var s = (string)v; Assert.AreEqual("", s); }
public void TrueTest() { var v = Json5.Parse("true"); var b = (bool)v; Assert.IsTrue(b); }
public void DoubleQuoteEmptyTest() { var v = Json5.Parse("\"\""); var s = (string)v; Assert.AreEqual("", s); }
public void DecimalPointDigitTest() { var v = Json5.Parse("1.2"); var n = (double)v; Assert.AreEqual(1.2D, n); }
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"]); }