Ejemplo n.º 1
0
        public void ReadBytesSuccessfully()
        {
            var result = new List <sbyte>(mResult.Length);
            var reader = new BitsReader(mInput);

            for (int i = 1; i < 9; i++)
            {
                result.Add(reader.ReadInt8(i));
                result.Add(reader.ReadInt8(i));
            }

            Assert.AreEqual(mResult, result.ToArray());
        }
Ejemplo n.º 2
0
        public void ReadShouldThrow(byte[] input)
        {
            var reader = new BitsReader(input);

            for (int i = 0; i < 2; ++i)
            {
                reader.ReadInt8(8);
            }
        }
Ejemplo n.º 3
0
 private static void ReadMeExample1()
 {
     byte[] bytes  = { 25, 26, 27, 28, 29, 30, 31 };
     var    reader = new BitsReader(bytes);
     byte   A      = reader.ReadUInt8(4);
     short  B      = reader.ReadInt16(12);
     int    C      = reader.ReadInt32(24);
     ushort D      = reader.ReadUInt16(13);
     sbyte  E      = reader.ReadInt8(3);
 }
Ejemplo n.º 4
0
        private static void BitsReaderSample()
        {
            byte[] buffer1 = { 25, 26, 27, 28, 29, 30, 31, 32 };

            var reader = new BitsReader(buffer1);

            sbyte b  = reader.ReadInt8();
            sbyte b1 = reader.ReadInt8(1);
            sbyte b3 = reader.ReadInt8(3);
            sbyte b4 = reader.ReadInt8(4);

            short s   = reader.ReadInt16();
            short s1  = reader.ReadInt16(1);
            short s2  = reader.ReadInt16(2);
            short s4  = reader.ReadInt16(4);
            short s5  = reader.ReadInt16(5);
            short s8  = reader.ReadInt16(8);
            short s12 = reader.ReadInt16(12);

            //receive new data in buffer1
            reader.Reset(buffer1);

            int i1  = reader.ReadInt32(1);
            int i7  = reader.ReadInt32(7);
            int i24 = reader.ReadInt32(24);
            int i   = reader.ReadInt32();

            //receive new data in buffer1
            reader.Reset(buffer1);

            long l1  = reader.ReadInt64(1);
            long l3  = reader.ReadInt64(3);
            long l24 = reader.ReadInt64(24);
            long l36 = reader.ReadInt64(36);

            //receive new data in buffer1
            reader.Reset(buffer1);

            long l = reader.ReadInt64();
        }
Ejemplo n.º 5
0
        public void ResetSuccess()
        {
            var reader = new BitsReader(new byte[] { 86, 8 });

            reader.ReadInt16(12);

            Assert.AreNotEqual(0, reader.BitsRead);

            reader.Reset(new byte[] { 240 });

            Assert.AreEqual(0, reader.BitsRead);

            reader.ReadInt8(5);
        }