Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FixedStringBurstTests.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #if !UNITY_DOTSRUNTIME
  2. using System;
  3. using System.Globalization;
  4. using System.Threading;
  5. using NUnit.Framework;
  6. using Unity.Collections;
  7. using Unity.Collections.LowLevel.Unsafe;
  8. using System.Text;
  9. using Unity.Burst;
  10. // change this to change the core type under test
  11. using FixedStringN = Unity.Collections.FixedString128Bytes;
  12. namespace FixedStringTests
  13. {
  14. [BurstCompile]
  15. internal class FixedStringBurstTests
  16. {
  17. [BurstCompile]
  18. static int BurstAppendFn(ref FixedStringN fs, in FixedString32Bytes other)
  19. {
  20. fs.Append(in other);
  21. return fs.Length;
  22. }
  23. delegate int BurstAppendDelegate(ref FixedStringN a, in FixedString32Bytes b);
  24. [Test]
  25. public void TestBurstAppend()
  26. {
  27. var fp = BurstCompiler.CompileFunctionPointer<BurstAppendDelegate>(BurstAppendFn);
  28. var invoke = fp.Invoke;
  29. FixedStringN a = new FixedStringN("Hello ");
  30. FixedString32Bytes b = new FixedString32Bytes("World");
  31. var len = invoke(ref a, b);
  32. Assert.AreEqual(11, len);
  33. Assert.AreEqual("Hello World", a.ToString());
  34. }
  35. }
  36. }
  37. #endif