Ejemplo n.º 1
0
        public void T3_1()
        {
            var arr = new byte[]{1,2,3,4,5};
            var s = new BufferSegmentReadingStream();

            s.BindBuffer(arr, 2, 3);

            Assert.AreEqual(0, s.Position);
            Assert.AreEqual(3, s.Length);

            var a2 = new byte[10];

            Assert.AreEqual(3,  s.Read(a2, 0, 10));
            Assert.AreEqual(3, a2[0]);
            Assert.AreEqual(4, a2[1]);
            Assert.AreEqual(5, a2[2]);
            Assert.AreEqual(0, a2[3]);
            Assert.AreEqual(3, s.Position);
        }
Ejemplo n.º 2
0
        public void T2()
        {
            var arr = new byte[]{1,2,3,4,5};
            var s = new BufferSegmentReadingStream();

            s.BindBuffer(arr, 0, 3);

            Assert.AreEqual(3, s.Length);

              Assert.AreEqual(0, s.Position);
            Assert.AreEqual(1, s.ReadByte());
              Assert.AreEqual(1, s.Position);
            Assert.AreEqual(2, s.ReadByte());
              Assert.AreEqual(2, s.Position);
            Assert.AreEqual(3, s.ReadByte());
              Assert.AreEqual(3, s.Position);
            Assert.AreEqual(-1, s.ReadByte());
              Assert.AreEqual(3, s.Position);
        }
Ejemplo n.º 3
0
 private BufferSegmentReadingStream getTLReadStream(byte[] buf, long idxStart, long count)
 {
   BufferSegmentReadingStream result = ts_ReadStream;
   if (result==null)
   {
    result = new BufferSegmentReadingStream();
    ts_ReadStream = result;
   }
   result.BindBuffer(buf, idxStart, count);
   return result;
 }
Ejemplo n.º 4
0
        public void T8()
        {
            var arr = new byte[]{1,2,3,4,5};
            var s = new BufferSegmentReadingStream();

            s.BindBuffer(arr, 2, 3);

            Assert.AreEqual(3, s.Length);

              Assert.AreEqual(0, s.Position);
            Assert.AreEqual(3, s.ReadByte());
              Assert.AreEqual(1, s.Position);
            Assert.AreEqual(4, s.ReadByte());
              Assert.AreEqual(2, s.Position);
            Assert.AreEqual(5, s.ReadByte());
              Assert.AreEqual(3, s.Position);
            Assert.AreEqual(-1, s.ReadByte());
              Assert.AreEqual(3, s.Position);

            var arr2 = new byte[]{101,102,103,104,105,106,107,108,109,110};

            s.BindBuffer(arr2, 2, 3);

            Assert.AreEqual(3, s.Length);

              Assert.AreEqual(0, s.Position);
            Assert.AreEqual(103, s.ReadByte());
              Assert.AreEqual(1, s.Position);
            Assert.AreEqual(104, s.ReadByte());
              Assert.AreEqual(2, s.Position);
            Assert.AreEqual(105, s.ReadByte());
              Assert.AreEqual(3, s.Position);
            Assert.AreEqual(-1, s.ReadByte());
              Assert.AreEqual(3, s.Position);
        }
Ejemplo n.º 5
0
        public void T7()
        {
            var arr = new byte[]{1,2,3,4,5};
            var s = new BufferSegmentReadingStream();

            Assert.Throws<NFXIOException>( () =>  s.BindBuffer(arr, 22, 3) );
            Assert.Throws<NFXIOException>( () =>  s.BindBuffer(arr, 0, 23) );
            Assert.Throws<NFXIOException>( () =>  s.BindBuffer(arr, -1, 1) );
            Assert.Throws<NFXIOException>( () =>  s.BindBuffer(arr, 0, -1) );
        }
Ejemplo n.º 6
0
        public void T6()
        {
            var arr = new byte[]{1,2,3,4,5};
            var s = new BufferSegmentReadingStream();
            var ms = new MemoryStream(arr, 2, 3);

            s.BindBuffer(arr, 2, 3);

            Assert.AreEqual(3, ms.Length);
            Assert.AreEqual(3, s.Length);

            s.Seek(1, SeekOrigin.Current);
            ms.Seek(1, SeekOrigin.Current);
            Assert.AreEqual(1, ms.Position);
            Assert.AreEqual(4, ms.ReadByte());
            Assert.AreEqual(1, s.Position);
            Assert.AreEqual(4, s.ReadByte());

            s.Seek(-1, SeekOrigin.Current);
            ms.Seek(-1, SeekOrigin.Current);
            Assert.AreEqual(1, ms.Position);
            Assert.AreEqual(4, ms.ReadByte());
            Assert.AreEqual(1, s.Position);
            Assert.AreEqual(4, s.ReadByte());
        }