Пример #1
0
        public void CreateStreamWithPartOfSourceByteArray()
        {
            byte[] byteArray =
            {
                (byte)'s', (byte)'o', (byte)'m', (byte)'e',
                (byte)' ', (byte)'d', (byte)'a', (byte)'t', (byte)'a'
            };

            BitStream bitStream;

            using (bitStream = new BitStream(byteArray, Allocator.Persistent, 4))
            {
                Assert.AreEqual(bitStream.Length, 4);
                var slice = new BitSlice(ref bitStream, 0, bitStream.Length);
                for (int i = 0; i < slice.Length; ++i)
                {
                    Assert.AreEqual(byteArray[i], slice.ReadByte());
                }
                // TODO: Make sure it doesn't read out of bounds
                Assert.AreNotEqual((byte)' ', slice.ReadByte());
            }
        }
Пример #2
0
        public void CreateStreamWithSourceByteArray()
        {
            byte[] byteArray = new byte[100];
            byteArray[0] = (byte)'a';
            byteArray[1] = (byte)'b';
            byteArray[2] = (byte)'c';

            BitStream bitStream;

            using (bitStream = new BitStream(byteArray, Allocator.Persistent))
            {
                var slice = new BitSlice(ref bitStream, 0, byteArray.Length);
                for (int i = 0; i < slice.Length; ++i)
                {
                    Assert.AreEqual(byteArray[i], slice.ReadByte());
                }
            }
        }