2023-08-27 16:37:49 +08:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
2021-08-25 08:31:13 +08:00
|
|
|
using Xunit;
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
|
|
|
namespace SharpNBT.Tests
|
|
|
|
{
|
|
|
|
public class ConversionTest
|
|
|
|
{
|
|
|
|
private readonly ITestOutputHelper output;
|
2021-08-25 10:24:28 +08:00
|
|
|
private readonly CompoundTag tag;
|
2021-08-25 08:31:13 +08:00
|
|
|
|
|
|
|
public ConversionTest(ITestOutputHelper output)
|
|
|
|
{
|
|
|
|
this.output = output;
|
2021-08-25 10:24:28 +08:00
|
|
|
tag = TestHelper.GetTag("bigtest.nbt", CompressionType.GZip);
|
2021-08-25 08:31:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void JsonOutput1()
|
|
|
|
{
|
2021-08-25 10:24:28 +08:00
|
|
|
output.WriteLine(tag.ToJsonString(true));
|
2021-08-25 08:31:13 +08:00
|
|
|
}
|
2023-08-27 16:37:49 +08:00
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public unsafe void PinTest()
|
|
|
|
{
|
|
|
|
const int length = 69;
|
|
|
|
var ary = Enumerable.Range(420, length);
|
|
|
|
var intTag = new IntArrayTag("Foobar", ary);
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
fixed (int* ptr = &intTag.GetPinnableReference())
|
|
|
|
{
|
|
|
|
for (var i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
sb.Append(ptr[i]);
|
|
|
|
sb.Append(',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
output.WriteLine(sb.ToString());
|
|
|
|
}
|
2021-08-25 08:31:13 +08:00
|
|
|
}
|
|
|
|
}
|