Update tests to deserialize char so that they align better with the (#32636)
authorAhson Khan <ahson_ahmedk@yahoo.com>
Fri, 21 Feb 2020 05:46:23 +0000 (21:46 -0800)
committerGitHub <noreply@github.com>
Fri, 21 Feb 2020 05:46:23 +0000 (21:46 -0800)
behavior being tested.

src/libraries/System.Text.Json/tests/Serialization/Null.ReadTests.cs

index d3600ef..81bc7e7 100644 (file)
@@ -161,10 +161,11 @@ namespace System.Text.Json.Serialization.Tests
         public static void NullReadTestChar()
         {
             Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>("null"));
-            Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>(""));
-            Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>("1234"));
+            Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>("\"\""));
+            Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>(""));   // Empty JSON is invalid
+            Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>("1234")); // Can't convert a JSON number to JSON string/char
             Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>("\"stringTooLong\""));
-            Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>("\"\u0059\"B"));
+            Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>("\"\u0059B\""));
             Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>("\"\uD800\uDC00\""));
             Assert.Equal('a', JsonSerializer.Deserialize<char>("\"a\""));
             Assert.Equal('Y', JsonSerializer.Deserialize<char>("\"\u0059\""));