diff options
author | Steffen Kieß <s-kiess@web.de> | 2016-02-28 20:40:22 +0300 |
---|---|---|
committer | Steffen Kieß <s-kiess@web.de> | 2016-02-28 20:40:22 +0300 |
commit | 314568184ca6bf4dbe5e8dcca362747225de3102 (patch) | |
tree | ce13fff258fe37d99335878083e7a2f585e3ba8b /mcs/class/System.Json | |
parent | ab7138d5c9a98b5e3010722b8fd090db6e691649 (diff) |
Fix typo in JsonValue which broke the conversion to uint and add test case
Diffstat (limited to 'mcs/class/System.Json')
-rw-r--r-- | mcs/class/System.Json/System.Json/JsonValue.cs | 2 | ||||
-rw-r--r-- | mcs/class/System.Json/Test/System.Json/JsonValueTest.cs | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/mcs/class/System.Json/System.Json/JsonValue.cs b/mcs/class/System.Json/System.Json/JsonValue.cs index ac3f723e2ad..450d3bc58b6 100644 --- a/mcs/class/System.Json/System.Json/JsonValue.cs +++ b/mcs/class/System.Json/System.Json/JsonValue.cs @@ -442,7 +442,7 @@ namespace System.Json { if (value == null) throw new ArgumentNullException ("value"); - return Convert.ToUInt16 (((JsonPrimitive) value).Value, NumberFormatInfo.InvariantInfo); + return Convert.ToUInt32 (((JsonPrimitive) value).Value, NumberFormatInfo.InvariantInfo); } public static implicit operator ulong (JsonValue value) diff --git a/mcs/class/System.Json/Test/System.Json/JsonValueTest.cs b/mcs/class/System.Json/Test/System.Json/JsonValueTest.cs index 15d5bd82b38..b267bd7c98e 100644 --- a/mcs/class/System.Json/Test/System.Json/JsonValueTest.cs +++ b/mcs/class/System.Json/Test/System.Json/JsonValueTest.cs @@ -113,6 +113,30 @@ namespace MonoTests.System } [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 () { CheckDouble (0, "0"); @@ -262,3 +286,10 @@ namespace MonoTests.System } } } + +// vim: noexpandtab +// Local Variables: +// tab-width: 4 +// c-basic-offset: 4 +// indent-tabs-mode: t +// End: |