Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Köplinger <alex.koeplinger@outlook.com>2016-04-01 15:11:03 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2016-04-01 15:11:03 +0300
commit670c746e7e5f5d10f05897a697a8ae34f00ab226 (patch)
tree7394d4fc144095e6ee06dc79e37a2c6126855cb5 /mcs/class/System.Web.Extensions
parent5c8d6e96c1efc7684f5582ed607858d869625bfb (diff)
[System.Web.Extensions] Add test for last fix
Diffstat (limited to 'mcs/class/System.Web.Extensions')
-rw-r--r--mcs/class/System.Web.Extensions/Test/System.Web.Script.Serialization/JavaScriptSerializerTest.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/mcs/class/System.Web.Extensions/Test/System.Web.Script.Serialization/JavaScriptSerializerTest.cs b/mcs/class/System.Web.Extensions/Test/System.Web.Script.Serialization/JavaScriptSerializerTest.cs
index 8dc9e38c43b..61e4b502d66 100644
--- a/mcs/class/System.Web.Extensions/Test/System.Web.Script.Serialization/JavaScriptSerializerTest.cs
+++ b/mcs/class/System.Web.Extensions/Test/System.Web.Script.Serialization/JavaScriptSerializerTest.cs
@@ -1439,5 +1439,43 @@ namespace MonoTests.System.Web.Script.Serialization
Assert.AreEqual (1337.0, obj.d);
Assert.AreEqual (null, obj.o);
}
+
+ [Test]
+ public void DeserializeInCultureWithCommaSeparator ()
+ {
+ var origCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
+ CommaSeparatorTest ();
+
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("fi-FI");
+ CommaSeparatorTest ();
+ } finally {
+ Thread.CurrentThread.CurrentCulture = origCulture;
+ }
+ }
+
+ public class DoubleTest
+ {
+ public double[] value { get; set; }
+ }
+
+ void CommaSeparatorTest()
+ {
+ JavaScriptSerializer serializer = new JavaScriptSerializer ();
+
+ DoubleTest array = new DoubleTest ();
+ array.value = new[] { 123.345, 0.69 };
+
+ string arrayJson = serializer.Serialize (array);
+ Console.WriteLine (arrayJson);
+
+ // This throwed incorrectly a "System.ArgumentException: Invalid JSON primitive: 123.345" with a CurrentThread.CultureInfo that has a comma as the number separator.
+ DoubleTest obj = serializer.Deserialize<DoubleTest> (arrayJson);
+
+ Assert.AreEqual (123.345, obj.value[0], "#1");
+ Assert.AreEqual (0.69, obj.value[1], "#2");
+ }
}
}