diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-07-01 16:04:26 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-07-01 16:04:26 +0700 |
commit | 7667960b24e63b23518408337c69d5f36c5dfd94 (patch) | |
tree | 5a4d0d42d37cd2413b3ec7b68eccfb16f3d4a858 /crypto/test | |
parent | Rework EdDSA precomputations (diff) | |
download | BouncyCastle.NET-ed25519-7667960b24e63b23518408337c69d5f36c5dfd94.tar.xz |
Custom serialization
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/src/math/test/BigIntegerTest.cs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/crypto/test/src/math/test/BigIntegerTest.cs b/crypto/test/src/math/test/BigIntegerTest.cs index 8196cc6ec..f5973c197 100644 --- a/crypto/test/src/math/test/BigIntegerTest.cs +++ b/crypto/test/src/math/test/BigIntegerTest.cs @@ -1,8 +1,9 @@ using System; +using System.IO; +using System.Runtime.Serialization.Formatters.Binary; using NUnit.Framework; -using Org.BouncyCastle.Math; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Encoders; @@ -765,6 +766,25 @@ namespace Org.BouncyCastle.Math.Tests } [Test] + public void TestSerialization() + { + using (var buf = new MemoryStream()) + { + BigInteger x = new BigInteger(128, random); + object y; + + var formatter = new BinaryFormatter(); + formatter.Serialize(buf, x); + + buf.Position = 0; + y = formatter.Deserialize(buf); + + Assert.AreEqual(buf.Length, buf.Position); + Assert.AreEqual(x, y); + } + } + + [Test] public void TestSetBit() { Assert.AreEqual(one, zero.SetBit(0)); |