forked from mirror/DotRecast
added RcIO Tests
This commit is contained in:
parent
104b5b02b2
commit
e9c8b3eddf
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue