Example #1
0
    public void T08_Integer_Buffered_IO()
    {
        var buffer = new byte[10];

        for (int i = 0; i < 256; i++)
        {
            var n      = TT.PRNG.Next(Int32.MinValue, Int32.MaxValue);
            var x      = new X690.Integer(n);
            var length = x.Write(buffer, 0);
            TT.Peek(x, buffer, length);
            var y = (X690.Read(buffer, 0, length)) as X690.Integer;
            Assert.Equal(n, x.Value);
            Assert.Equal(x.ValueBits, y.ValueBits);
            Assert.Equal(n, y.Value);
            Assert.Equal(x.Header.MessageLength, length);
        }
    }
Example #2
0
 public void T07_Integer_Stream_IO()
 {
     for (int i = 0; i < 256; i++)
     {
         var n = TT.PRNG.Next(Int32.MinValue, Int32.MaxValue);
         using (var stream = new MemoryStream()) {
             var x = new X690.Integer(n);
             x.Write(stream);
             TT.Peek(x, stream);
             stream.Position = 0;
             var y = (X690.Read(stream)) as X690.Integer;
             Assert.Equal(n, x.Value);
             Assert.Equal(x.ValueBits, y.ValueBits);
             Assert.Equal(n, y.Value);
         }
     }
 }