-Added BigInteger support

This commit is contained in:
James Newton-King
2013-03-16 19:06:05 +13:00
parent b81dfd352a
commit 1356c31670
24 changed files with 957 additions and 50 deletions
@@ -25,6 +25,9 @@
using System;
using System.Globalization;
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
using System.Numerics;
#endif
using System.Text;
#if !NETFX_CORE
using NUnit.Framework;
@@ -1313,5 +1316,29 @@ namespace Newtonsoft.Json.Tests.Bson
Assert.AreEqual(badText, (string)o["test"]);
}
#endif
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
public class BigIntegerTestClass
{
public BigInteger Blah { get; set; }
}
[Test]
public void WriteBigInteger()
{
BigInteger i = BigInteger.Parse("1999999999999999999999999999999999999999999999999999999999990");
byte[] data = MiscellaneousUtils.HexToBytes("2A-00-00-00-05-42-6C-61-68-00-1A-00-00-00-00-F6-FF-FF-FF-FF-FF-FF-1F-B2-21-CB-28-59-84-C4-AE-03-8A-44-34-2F-4C-4E-9E-3E-01-00");
MemoryStream ms = new MemoryStream(data);
BsonReader reader = new BsonReader(ms);
JsonSerializer serializer = new JsonSerializer();
BigIntegerTestClass c = serializer.Deserialize<BigIntegerTestClass>(reader);
Assert.AreEqual(i, c.Blah);
}
#endif
}
}