Added fix for Bug 20869
[mono.git] / mcs / class / System.Json / Test / System.Json / JsonValueTest.cs
index 754f8556a5fea0dbef54f21fdc055342afd69f8e..c3347c689d9999f8bba2514beb75f6c2fedb7098 100644 (file)
@@ -25,5 +25,21 @@ namespace MonoTests.System
                        Assert.AreEqual (JsonType.String, j ["a"].JsonType, "type");
                        Assert.AreEqual ("b", (string) j ["a"], "value");
                }
+
+               // Test that we correctly serialize JsonArray with null elements.
+               [Test]
+               public void ToStringOnJsonArrayWithNulls () {
+                       var j = JsonValue.Load (new StringReader ("[1,2,3,null]"));
+                       Assert.AreEqual (4, j.Count, "itemcount");
+                       Assert.AreEqual (JsonType.Array, j.JsonType, "type");
+                       var str = j.ToString ();
+                       Assert.AreEqual (str, "[1, 2, 3, null]");
+               }
+
+               [Test]
+               public void QuoteEscapeBug_20869 () 
+               {
+                       Assert.AreEqual ((new JsonPrimitive ("\"\"")).ToString (), "\"\\\"\\\"\"");
+               }
        }
 }