Нема описа
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.1KB

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