Example #1
0
        public void DisposeWriterTest()
        {
            BitStreamer bs = new BitStreamer();

            bs.Dispose();

            bs.ResetWrite(16);
            bs.Dispose();
            Assert.AreEqual(IntPtr.Zero, bs.Buffer);

            bs.ResetWrite(18);
            Assert.AreEqual(24, bs.ByteLength);

            bs.Dispose();
            Assert.AreEqual(IntPtr.Zero, bs.Buffer);
            Assert.AreEqual(0, bs.BitLength);
            Assert.AreEqual(0, bs.BitOffset);
            Assert.AreEqual(SerializationMode.None, bs.Mode);
        }
Example #2
0
        public unsafe void WriteBufferCopyTest()
        {
            ulong  value = 666;
            IntPtr buf   = Marshal.AllocHGlobal(8);

            BitStreamer reader = new BitStreamer();

            reader.ResetWrite(buf, 8, false);
            reader.WriteULong(value, 64);

            Assert.AreEqual(64, reader.BitLength);
            Assert.AreEqual(64, reader.BitOffset);

            Assert.AreEqual(value, *(ulong *)reader.Buffer);

            reader.Dispose();
        }
Example #3
0
        public void ResetWriteTest2()
        {
            BitStreamer bs = new BitStreamer();

            bs.ResetWrite(10);
            IntPtr ptr = bs.Buffer;

            Assert.AreEqual(16, bs.ByteLength);

            bs.ResetWrite(12);
            Assert.AreEqual(16, bs.ByteLength);
            Assert.AreEqual(ptr, bs.Buffer);
            bs.ResetWrite(17);

            Assert.AreEqual(24, bs.ByteLength);

            bs.Dispose();
            Assert.AreEqual(IntPtr.Zero, bs.Buffer);
        }