summary refs log tree commit diff
path: root/crypto/test
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/src/math/test/BigIntegerTest.cs22
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));