public void WriteResizeTest() { BitStreamer bs = new BitStreamer(false); Assert.IsFalse(bs.ThrowsOnExceededBuffer); Assert.IsFalse(bs.IsValid); bs.ResetWrite(8); Assert.IsTrue(bs.IsValid); bs.WriteULong(123); Assert.IsTrue(bs.IsValid); Assert.AreEqual(8, bs.ByteLength); bs.WriteInt32(321); Assert.IsTrue(bs.IsValid); Assert.AreEqual(16, bs.ByteLength); // Confirm offset has increased. Assert.AreEqual(12, bs.ByteOffset); bs.ResetRead(); Assert.AreEqual(123, bs.ReadULong()); Assert.AreEqual(321, bs.ReadInt32()); Assert.IsTrue(bs.IsValid); }
public unsafe void ReadBufferCopyTest() { ulong value = 85830981411525; IntPtr buf = Marshal.AllocHGlobal(8); *(ulong *)buf = value; BitStreamer reader = new BitStreamer(); reader.ResetRead(buf, 8, false); Assert.AreEqual(64, reader.BitLength); Assert.AreEqual(0, reader.BitOffset); Assert.AreEqual(value, reader.ReadULong()); }