study/first_study/Library/PackageCache/com.unity.collections@aea9d3bd5e19/Unity.Collections.Tests/FixedStringBurstTests.cs
jh04010421 739d49f1a0 Unity | 2026.01.20
수업 실습 파일
2026-01-20 11:01:57 +09:00

42 lines
1.1 KiB
C#

using System;
using System.Globalization;
using System.Threading;
using NUnit.Framework;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using System.Text;
using Unity.Burst;
// change this to change the core type under test
using FixedStringN = Unity.Collections.FixedString128Bytes;
namespace FixedStringTests
{
[BurstCompile]
internal class FixedStringBurstTests
{
[BurstCompile]
static int BurstAppendFn(ref FixedStringN fs, in FixedString32Bytes other)
{
fs.Append(in other);
return fs.Length;
}
delegate int BurstAppendDelegate(ref FixedStringN a, in FixedString32Bytes b);
[Test]
public void TestBurstAppend()
{
var fp = BurstCompiler.CompileFunctionPointer<BurstAppendDelegate>(BurstAppendFn);
var invoke = fp.Invoke;
FixedStringN a = new FixedStringN("Hello ");
FixedString32Bytes b = new FixedString32Bytes("World");
var len = invoke(ref a, b);
Assert.AreEqual(11, len);
Assert.AreEqual("Hello World", a.ToString());
}
}
}