added RcIO Tests

This commit is contained in:
ikpil 2024-05-27 00:01:14 +09:00
parent 104b5b02b2
commit e9c8b3eddf
1 changed files with 38 additions and 0 deletions

View File

@ -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));
}
}
}