2024-09-05 16:57:28 +03:00
|
|
|
using System;
|
2024-05-26 18:01:14 +03:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|