diff --git a/test/DotRecast.Core.Test/RcIoTests.cs b/test/DotRecast.Core.Test/RcIoTests.cs new file mode 100644 index 0000000..c54d50b --- /dev/null +++ b/test/DotRecast.Core.Test/RcIoTests.cs @@ -0,0 +1,38 @@ +using System; +using System.IO; +using NUnit.Framework; + +namespace DotRecast.Core.Test; + +public class RcIoTests +{ + [Test] + public void Test() + { + const long tileRef = 281474976710656L; + const int dataSize = 344; + + byte[] actual; + + { + using MemoryStream ms = new MemoryStream(); + using BinaryWriter bw = new BinaryWriter(ms); + + RcIO.Write(bw, tileRef, RcByteOrder.LITTLE_ENDIAN); + RcIO.Write(bw, dataSize, RcByteOrder.LITTLE_ENDIAN); + + bw.Flush(); + actual= ms.ToArray(); + } + + { + using MemoryStream ms = new MemoryStream(actual); + using BinaryReader br = new BinaryReader(ms); + var byteBuffer = RcIO.ToByteBuffer(br); + byteBuffer.Order(RcByteOrder.LITTLE_ENDIAN); + + Assert.That(byteBuffer.GetLong(), Is.EqualTo(tileRef)); + Assert.That(byteBuffer.GetInt(), Is.EqualTo(dataSize)); + } + } +} \ No newline at end of file