Assert.AreEqual (JsonType.Array, j.JsonType, "type");
var str = j.ToString ();
Assert.AreEqual (str, "[1, 2, 3, null]");
+ ((JsonArray) j).Add (null);
+ str = j.ToString ();
+ Assert.AreEqual (str, "[1, 2, 3, null, null]");
+ }
+
+ // Test that we correctly serialize JsonObject with null elements.
+ [Test]
+ public void ToStringOnJsonObjectWithNulls () {
+ var j = JsonValue.Load (new StringReader ("{\"a\":null,\"b\":2}"));
+ Assert.AreEqual (2, j.Count, "itemcount");
+ Assert.AreEqual (JsonType.Object, j.JsonType, "type");
+ var str = j.ToString ();
+ Assert.AreEqual (str, "{\"a\": null, \"b\": 2}");
+ }
+
+ [Test]
+ public void JsonObjectOrder () {
+ var obj = new JsonObject ();
+ obj["a"] = 1;
+ obj["c"] = 3;
+ obj["b"] = 2;
+ var str = obj.ToString ();
+ Assert.AreEqual (str, "{\"a\": 1, \"b\": 2, \"c\": 3}");
}
[Test]
Assert.AreEqual (number, jvalue); // should be exactly the same
}
+ [Test]
+ public void CheckIntegers ()
+ {
+ Assert.AreEqual (sbyte.MinValue, (sbyte) JsonValue.Parse (new JsonPrimitive (sbyte.MinValue).ToString ()));
+ Assert.AreEqual (sbyte.MaxValue, (sbyte) JsonValue.Parse (new JsonPrimitive (sbyte.MaxValue).ToString ()));
+ Assert.AreEqual (byte.MinValue, (byte) JsonValue.Parse (new JsonPrimitive (byte.MinValue).ToString ()));
+ Assert.AreEqual (byte.MaxValue, (byte) JsonValue.Parse (new JsonPrimitive (byte.MaxValue).ToString ()));
+
+ Assert.AreEqual (short.MinValue, (short) JsonValue.Parse (new JsonPrimitive (short.MinValue).ToString ()));
+ Assert.AreEqual (short.MaxValue, (short) JsonValue.Parse (new JsonPrimitive (short.MaxValue).ToString ()));
+ Assert.AreEqual (ushort.MinValue, (ushort) JsonValue.Parse (new JsonPrimitive (ushort.MinValue).ToString ()));
+ Assert.AreEqual (ushort.MaxValue, (ushort) JsonValue.Parse (new JsonPrimitive (ushort.MaxValue).ToString ()));
+
+ Assert.AreEqual (int.MinValue, (int) JsonValue.Parse (new JsonPrimitive (int.MinValue).ToString ()));
+ Assert.AreEqual (int.MaxValue, (int) JsonValue.Parse (new JsonPrimitive (int.MaxValue).ToString ()));
+ Assert.AreEqual (uint.MinValue, (uint) JsonValue.Parse (new JsonPrimitive (uint.MinValue).ToString ()));
+ Assert.AreEqual (uint.MaxValue, (uint) JsonValue.Parse (new JsonPrimitive (uint.MaxValue).ToString ()));
+
+ Assert.AreEqual (long.MinValue, (long) JsonValue.Parse (new JsonPrimitive (long.MinValue).ToString ()));
+ Assert.AreEqual (long.MaxValue, (long) JsonValue.Parse (new JsonPrimitive (long.MaxValue).ToString ()));
+ Assert.AreEqual (ulong.MinValue, (ulong) JsonValue.Parse (new JsonPrimitive (ulong.MinValue).ToString ()));
+ Assert.AreEqual (ulong.MaxValue, (ulong) JsonValue.Parse (new JsonPrimitive (ulong.MaxValue).ToString ()));
+ }
+
[Test]
public void CheckNumbers ()
{
}
}
}
+
+// vim: noexpandtab
+// Local Variables:
+// tab-width: 4
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// End: