Be.IO icon indicating copy to clipboard operation
Be.IO copied to clipboard

Fix ReadInt64 issue

Open UlyssesWu opened this issue 8 years ago • 1 comments

There was a mistake when reading a 8 bytes value. Can be tested with following code:

    [TestMethod]
    public void TestUInt64()
    {
        using (MemoryStream ms = new MemoryStream())
        {
            ulong src = 1;
            var bw = new BeBinaryWriter(ms);
            bw.Write(src);
            bw.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            var br = new BeBinaryReader(ms);
            var dst = br.ReadUInt64();
            Assert.AreEqual(src, dst); //Expect 1, Actual 4294967296
        }
    }

By the way, I haven't figure out how to create a UnitTest project for this lib --- VS refused to add this lib as a reference when creating a VSUnitTest project. (Maybe DNX project is not supported?)

UlyssesWu avatar Apr 10 '16 12:04 UlyssesWu

Oh, and I think maybe you should fix the Readme.md :

writer.WriteInt16(0x1357);
writer.WriteInt32(0xDEADBEEF);
writer.WriteInt64(long.MinValue); //tricky, since it's always right when test 

There are no methods like these, after all :joy:

UlyssesWu avatar Apr 10 '16 12:04 UlyssesWu