From 086a6e0f30d12ba01bbbcec0ef68ac352c82bc1b Mon Sep 17 00:00:00 2001 From: Leonardo Nascimento Date: Wed, 19 Aug 2020 12:41:05 -0300 Subject: [PATCH] Added test for cd1f67f --- LiteDB.Tests/Document/Json_Tests.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/LiteDB.Tests/Document/Json_Tests.cs b/LiteDB.Tests/Document/Json_Tests.cs index b577bcdfa..556dda2c1 100644 --- a/LiteDB.Tests/Document/Json_Tests.cs +++ b/LiteDB.Tests/Document/Json_Tests.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using FluentAssertions; using Xunit; @@ -56,5 +57,23 @@ public void JsonWriterTest() var specialChars = "ÁÀÃÂÄÉÈÊËÉÍÌÎÏÓÒÕÔÖÚÙÛÜÇáàãâäéèêëéíìîïóòõôöúùûüç"; JsonSerializer.Serialize(specialChars).Should().Be('\"' + specialChars + '\"'); } + + [Fact] + public void Json_Number_Deserialize_Test() + { + int positiveInt32 = 5000000; + int negativeInt32 = -5000000; + long positiveInt64 = 210000000000L; + long negativeInt64 = -210000000000L; + double positiveDouble = 210000000000D; + double negativeDouble = -210000000000D; + + JsonSerializer.Deserialize(positiveInt32.ToString()).Should().Be(positiveInt32); + JsonSerializer.Deserialize(negativeInt32.ToString()).Should().Be(negativeInt32); + JsonSerializer.Deserialize(positiveInt64.ToString()).Should().Be(positiveInt64); + JsonSerializer.Deserialize(negativeInt64.ToString()).Should().Be(negativeInt64); + JsonSerializer.Deserialize(positiveDouble.ToString("F1", CultureInfo.InvariantCulture)).Should().Be(positiveDouble); + JsonSerializer.Deserialize(negativeDouble.ToString("F1", CultureInfo.InvariantCulture)).Should().Be(negativeDouble); + } } } \ No newline at end of file