SceneGate / Yarhl

Framework for the implementation of format converters like game assets or media files
https://scenegate.github.io/Yarhl/
MIT License
60 stars 10 forks source link

DataStream.Compare with itself doesn't work properly #189

Closed priverop closed 9 months ago

priverop commented 2 years ago

Describe the bug DataStream.Compare returns false when it should return true when comparing a Stream with itself.

To Reproduce Using Yarhl 4.0.0-preview.157.

    public class TestObject : IBinary
    {
        public TestObject(DataStream fileStream)
        {
            Stream = fileStream;
        }

        public DataStream Stream { get; set; }
}

public void Test(){
            var streamA = new DataStream();
            streamA.Write(new byte[] { 1, 2, 3 }, 0, 3);

            var alarFile = new TestObject(streamA);

            var streamB = new DataStream();
            streamB.Write(new byte[] { 2, 3, 4 }, 0, 3);

            alarFile.Stream = streamB;

            alarFile.Stream.Compare(streamB).Should().BeTrue();
}

Expected behavior That test should pass. Compare() should return true.

Desktop (please complete the following information):