No Description
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.

UnsafeListTests.cs 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. using NUnit.Framework;
  2. using System;
  3. using Unity.Burst;
  4. using Unity.Collections;
  5. using Unity.Collections.Tests;
  6. using Unity.Collections.LowLevel.Unsafe;
  7. using Unity.Jobs;
  8. internal class UnsafeListTests : CollectionsTestCommonBase
  9. {
  10. [Test]
  11. public unsafe void UnsafeListT_Init_ClearMemory()
  12. {
  13. var list = new UnsafeList<int>(10, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  14. for (var i = 0; i < list.Length; ++i)
  15. {
  16. Assert.AreEqual(0, UnsafeUtility.ReadArrayElement<int>(list.Ptr, i));
  17. }
  18. list.Dispose();
  19. }
  20. [Test]
  21. public unsafe void UnsafeListT_Allocate_Deallocate_Read_Write()
  22. {
  23. var list = new UnsafeList<int>(0, Allocator.Persistent);
  24. list.Add(1);
  25. list.Add(2);
  26. Assert.AreEqual(2, list.Length);
  27. Assert.AreEqual(1, UnsafeUtility.ReadArrayElement<int>(list.Ptr, 0));
  28. Assert.AreEqual(2, UnsafeUtility.ReadArrayElement<int>(list.Ptr, 1));
  29. list.Dispose();
  30. }
  31. [Test]
  32. public unsafe void UnsafeListT_Resize_ClearMemory()
  33. {
  34. var list = new UnsafeList<int>(5, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  35. list.SetCapacity(32);
  36. var capacity = list.Capacity;
  37. list.Resize(5, NativeArrayOptions.UninitializedMemory);
  38. Assert.AreEqual(capacity, list.Capacity); // list capacity should not change on resize
  39. for (var i = 0; i < 5; ++i)
  40. {
  41. UnsafeUtility.WriteArrayElement(list.Ptr, i, i);
  42. }
  43. list.Resize(10, NativeArrayOptions.ClearMemory);
  44. Assert.AreEqual(capacity, list.Capacity); // list capacity should not change on resize
  45. for (var i = 0; i < 5; ++i)
  46. {
  47. Assert.AreEqual(i, UnsafeUtility.ReadArrayElement<int>(list.Ptr, i));
  48. }
  49. for (var i = 5; i < list.Length; ++i)
  50. {
  51. Assert.AreEqual(0, UnsafeUtility.ReadArrayElement<int>(list.Ptr, i));
  52. }
  53. list.Dispose();
  54. }
  55. [Test]
  56. public unsafe void UnsafeListT_Resize_Zero()
  57. {
  58. var list = new UnsafeList<int>(5, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  59. var capacity = list.Capacity;
  60. list.Add(1);
  61. list.Resize(0);
  62. Assert.AreEqual(0, list.Length);
  63. Assert.AreEqual(capacity, list.Capacity); // list capacity should not change on resize
  64. list.Add(2);
  65. list.Clear();
  66. Assert.AreEqual(0, list.Length);
  67. Assert.AreEqual(capacity, list.Capacity); // list capacity should not change on resize
  68. list.Dispose();
  69. }
  70. [Test]
  71. public unsafe void UnsafeListT_SetCapacity()
  72. {
  73. using (var list = new UnsafeList<int>(1, Allocator.Persistent, NativeArrayOptions.ClearMemory))
  74. {
  75. list.Add(1);
  76. Assert.DoesNotThrow(() => list.SetCapacity(128));
  77. list.Add(1);
  78. Assert.AreEqual(2, list.Length);
  79. Assert.Throws<ArgumentOutOfRangeException>(() => list.SetCapacity(1));
  80. list.RemoveAtSwapBack(0);
  81. Assert.AreEqual(1, list.Length);
  82. Assert.DoesNotThrow(() => list.SetCapacity(1));
  83. list.TrimExcess();
  84. Assert.AreEqual(1, list.Capacity);
  85. }
  86. }
  87. [Test]
  88. public unsafe void UnsafeListT_TrimExcess()
  89. {
  90. using (var list = new UnsafeList<int>(32, Allocator.Persistent, NativeArrayOptions.ClearMemory))
  91. {
  92. list.Add(1);
  93. list.TrimExcess();
  94. Assert.AreEqual(1, list.Length);
  95. Assert.AreEqual(1, list.Capacity);
  96. list.RemoveAtSwapBack(0);
  97. Assert.AreEqual(list.Length, 0);
  98. list.TrimExcess();
  99. Assert.AreEqual(list.Capacity, 0);
  100. list.Add(1);
  101. Assert.AreEqual(list.Length, 1);
  102. Assert.AreNotEqual(list.Capacity, 0);
  103. list.Clear();
  104. }
  105. }
  106. [Test]
  107. public unsafe void UnsafeListT_DisposeJob()
  108. {
  109. var list = new UnsafeList<int>(5, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  110. var disposeJob = list.Dispose(default);
  111. Assert.IsTrue(list.Ptr == null);
  112. disposeJob.Complete();
  113. }
  114. unsafe void Expected(ref UnsafeList<int> list, int expectedLength, int[] expected)
  115. {
  116. Assert.AreEqual(0 == expectedLength, list.IsEmpty);
  117. Assert.AreEqual(list.Length, expectedLength);
  118. for (var i = 0; i < list.Length; ++i)
  119. {
  120. var value = UnsafeUtility.ReadArrayElement<int>(list.Ptr, i);
  121. Assert.AreEqual(expected[i], value);
  122. }
  123. }
  124. [Test]
  125. public unsafe void UnsafeListT_AddNoResize()
  126. {
  127. var list = new UnsafeList<int>(1, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  128. // List's capacity is always cache-line aligned, number of items fills up whole cache-line.
  129. int[] range = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
  130. Assert.Throws<Exception>(() => { fixed (int* r = range) list.AddRangeNoResize(r, 17); });
  131. list.SetCapacity(17);
  132. Assert.DoesNotThrow(() => { fixed (int* r = range) list.AddRangeNoResize(r, 17); });
  133. list.Length = 16;
  134. list.TrimExcess();
  135. Assert.Throws<Exception>(() => { list.AddNoResize(16); });
  136. }
  137. [Test]
  138. public unsafe void UnsafeListT_AddNoResize_Read()
  139. {
  140. var list = new UnsafeList<int>(4, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  141. list.AddNoResize(4);
  142. list.AddNoResize(6);
  143. list.AddNoResize(4);
  144. list.AddNoResize(9);
  145. Expected(ref list, 4, new int[] { 4, 6, 4, 9 });
  146. list.Dispose();
  147. }
  148. [Test]
  149. public unsafe void UnsafeListT_RemoveAtSwapBack()
  150. {
  151. var list = new UnsafeList<int>(10, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  152. int[] range = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  153. // test removing from the end
  154. fixed (int* r = range) list.AddRange(r, 10);
  155. list.RemoveAtSwapBack(list.Length - 1);
  156. Expected(ref list, 9, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
  157. list.Clear();
  158. // test removing from the end
  159. fixed (int* r = range) list.AddRange(r, 10);
  160. list.RemoveAtSwapBack(5);
  161. Expected(ref list, 9, new int[] { 0, 1, 2, 3, 4, 9, 6, 7, 8 });
  162. list.Clear();
  163. list.Dispose();
  164. }
  165. [Test]
  166. public unsafe void UnsafeListT_RemoveRangeSwapBackBE()
  167. {
  168. var list = new UnsafeList<int>(10, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  169. int[] range = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  170. // test removing from the end
  171. fixed (int* r = range) list.AddRange(r, 10);
  172. list.RemoveRangeSwapBack(6, 3);
  173. Expected(ref list, 7, new int[] { 0, 1, 2, 3, 4, 5, 9 });
  174. list.Clear();
  175. // test removing all but one
  176. fixed (int* r = range) list.AddRange(r, 10);
  177. list.RemoveRangeSwapBack(0, 9);
  178. Expected(ref list, 1, new int[] { 9 });
  179. list.Clear();
  180. // test removing from the front
  181. fixed (int* r = range) list.AddRange(r, 10);
  182. list.RemoveRangeSwapBack(0, 3);
  183. Expected(ref list, 7, new int[] { 7, 8, 9, 3, 4, 5, 6 });
  184. list.Clear();
  185. // test removing from the middle
  186. fixed (int* r = range) list.AddRange(r, 10);
  187. list.RemoveRangeSwapBack(0, 3);
  188. Expected(ref list, 7, new int[] { 7, 8, 9, 3, 4, 5, 6 });
  189. list.Clear();
  190. // test removing whole range
  191. fixed (int* r = range) list.AddRange(r, 10);
  192. list.RemoveRangeSwapBack(0, 10);
  193. Expected(ref list, 0, new int[] { 0 });
  194. list.Clear();
  195. list.Dispose();
  196. }
  197. [Test]
  198. public unsafe void UnsafeListT_RemoveAt()
  199. {
  200. var list = new UnsafeList<int>(10, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  201. int[] range = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  202. // test removing from the end
  203. fixed (int* r = range) list.AddRange(r, 10);
  204. list.RemoveAt(list.Length - 1);
  205. Expected(ref list, 9, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
  206. list.Clear();
  207. // test removing from the end
  208. fixed (int* r = range) list.AddRange(r, 10);
  209. list.RemoveAt(5);
  210. Expected(ref list, 9, new int[] { 0, 1, 2, 3, 4, 6, 7, 8, 9 });
  211. list.Clear();
  212. list.Dispose();
  213. }
  214. [Test]
  215. public unsafe void UnsafeListT_RemoveRange()
  216. {
  217. var list = new UnsafeList<int>(10, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  218. int[] range = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  219. // test removing from the end
  220. fixed (int* r = range) list.AddRange(r, 10);
  221. list.RemoveRange(6, 3);
  222. Expected(ref list, 7, new int[] { 0, 1, 2, 3, 4, 5, 9 });
  223. list.Clear();
  224. // test removing all but one
  225. fixed (int* r = range) list.AddRange(r, 10);
  226. list.RemoveRange(0, 9);
  227. Expected(ref list, 1, new int[] { 9 });
  228. list.Clear();
  229. // test removing from the front
  230. fixed (int* r = range) list.AddRange(r, 10);
  231. list.RemoveRange(0, 3);
  232. Expected(ref list, 7, new int[] { 3, 4, 5, 6, 7, 8, 9 });
  233. list.Clear();
  234. // test removing from the middle
  235. fixed (int* r = range) list.AddRange(r, 10);
  236. list.RemoveRange(0, 3);
  237. Expected(ref list, 7, new int[] { 3, 4, 5, 6, 7, 8, 9 });
  238. list.Clear();
  239. // test removing whole range
  240. fixed (int* r = range) list.AddRange(r, 10);
  241. list.RemoveRange(0, 10);
  242. Expected(ref list, 0, new int[] { 0 });
  243. list.Clear();
  244. list.Dispose();
  245. }
  246. [Test]
  247. public unsafe void UnsafeListT_Remove_Throws()
  248. {
  249. var list = new UnsafeList<int>(10, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  250. int[] range = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  251. fixed (int* r = range) list.AddRange(r, 10);
  252. Assert.Throws<ArgumentOutOfRangeException>(() => { list.RemoveAt(100); });
  253. Assert.AreEqual(10, list.Length);
  254. Assert.Throws<ArgumentOutOfRangeException>(() => { list.RemoveAtSwapBack(100); });
  255. Assert.AreEqual(10, list.Length);
  256. Assert.Throws<ArgumentOutOfRangeException>(() => { list.RemoveRange(0, 100); });
  257. Assert.AreEqual(10, list.Length);
  258. Assert.Throws<ArgumentOutOfRangeException>(() => { list.RemoveRangeSwapBack(0, 100); });
  259. Assert.AreEqual(10, list.Length);
  260. Assert.Throws<ArgumentOutOfRangeException>(() => { list.RemoveRange(100, -1); });
  261. Assert.AreEqual(10, list.Length);
  262. Assert.Throws<ArgumentOutOfRangeException>(() => { list.RemoveRangeSwapBack(100, -1); });
  263. Assert.AreEqual(10, list.Length);
  264. list.Dispose();
  265. }
  266. [Test]
  267. public unsafe void UnsafeListT_PtrLength()
  268. {
  269. var list = new UnsafeList<int>(10, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  270. int[] range = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  271. fixed (int* r = range) list.AddRange(r, 10);
  272. var listView = new UnsafeList<int>(list.Ptr + 4, 2);
  273. Expected(ref listView, 2, new int[] { 4, 5 });
  274. listView.Dispose();
  275. list.Dispose();
  276. }
  277. // Burst error BC1071: Unsupported assert type
  278. // [BurstCompile(CompileSynchronously = true)]
  279. struct UnsafeListParallelReader : IJob
  280. {
  281. public UnsafeList<int>.ParallelReader list;
  282. public void Execute()
  283. {
  284. Assert.True(list.Contains(123));
  285. }
  286. }
  287. [Test]
  288. public void UnsafeListT_ParallelReader()
  289. {
  290. var list = new UnsafeList<int>(10, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  291. list.Add(123);
  292. var job = new UnsafeListParallelReader
  293. {
  294. list = list.AsParallelReader(),
  295. };
  296. list.Dispose(job.Schedule()).Complete();
  297. }
  298. [BurstCompile(CompileSynchronously = true)]
  299. struct UnsafeListParallelWriter : IJobParallelFor
  300. {
  301. public UnsafeList<int>.ParallelWriter list;
  302. public void Execute(int index)
  303. {
  304. list.AddNoResize(index);
  305. }
  306. }
  307. [Test]
  308. public void UnsafeListT_ParallelWriter()
  309. {
  310. var list = new UnsafeList<int>(256, Allocator.Persistent, NativeArrayOptions.ClearMemory);
  311. var job = new UnsafeListParallelWriter
  312. {
  313. list = list.AsParallelWriter(),
  314. };
  315. job.Schedule(list.Capacity, 1).Complete();
  316. Assert.AreEqual(list.Length, list.Capacity);
  317. list.Sort<int>();
  318. for (int i = 0; i < list.Length; i++)
  319. {
  320. unsafe
  321. {
  322. var value = UnsafeUtility.ReadArrayElement<int>(list.Ptr, i);
  323. Assert.AreEqual(i, value);
  324. }
  325. }
  326. list.Dispose();
  327. }
  328. [BurstCompile(CompileSynchronously = true)]
  329. struct UnsafeListTestParallelWriter : IJob
  330. {
  331. [WriteOnly]
  332. public UnsafeList<int>.ParallelWriter writer;
  333. public unsafe void Execute()
  334. {
  335. var range = stackalloc int[2] { 7, 3 };
  336. writer.AddNoResize(range[0]);
  337. writer.AddRangeNoResize(range, 1);
  338. }
  339. }
  340. [Test]
  341. public void UnsafeListT_ParallelWriter_NoPtrCaching()
  342. {
  343. UnsafeList<int> list;
  344. {
  345. list = new UnsafeList<int>(2, Allocator.Persistent);
  346. var writer = list.AsParallelWriter();
  347. list.SetCapacity(100);
  348. var writerJob = new UnsafeListTestParallelWriter { writer = writer }.Schedule();
  349. writerJob.Complete();
  350. }
  351. Assert.AreEqual(2, list.Length);
  352. Assert.AreEqual(7, list[0]);
  353. Assert.AreEqual(7, list[1]);
  354. list.Dispose();
  355. }
  356. [Test]
  357. public unsafe void UnsafeListT_IndexOf()
  358. {
  359. using (var list = new UnsafeList<int>(10, Allocator.Persistent) { 123, 789 })
  360. {
  361. bool r0 = false, r1 = false, r2 = false;
  362. GCAllocRecorder.ValidateNoGCAllocs(() =>
  363. {
  364. r0 = -1 != list.IndexOf(456);
  365. r1 = list.Contains(123);
  366. r2 = list.Contains(789);
  367. });
  368. Assert.False(r0);
  369. Assert.True(r1);
  370. Assert.True(r2);
  371. }
  372. }
  373. [Test]
  374. public void UnsafeListT_InsertRangeWithBeginEnd()
  375. {
  376. var list = new UnsafeList<byte>(3, Allocator.Persistent);
  377. list.Add(0);
  378. list.Add(3);
  379. list.Add(4);
  380. Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRangeWithBeginEnd(-1, 8));
  381. Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRangeWithBeginEnd(0, 8));
  382. Assert.Throws<ArgumentException>(() => list.InsertRangeWithBeginEnd(3, 1));
  383. Assert.DoesNotThrow(() => list.InsertRangeWithBeginEnd(1, 3));
  384. list[1] = 1;
  385. list[2] = 2;
  386. for (var i = 0; i < 5; ++i)
  387. {
  388. Assert.AreEqual(i, list[i]);
  389. }
  390. list.Dispose();
  391. }
  392. [Test]
  393. public void UnsafeListT_ForEach([Values(10, 1000)] int n)
  394. {
  395. var seen = new NativeArray<int>(n, Allocator.Temp);
  396. using (var container = new UnsafeList<int>(32, CommonRwdAllocator.Handle))
  397. {
  398. for (int i = 0; i < n; i++)
  399. {
  400. container.Add(i);
  401. }
  402. var count = 0;
  403. unsafe
  404. {
  405. UnsafeList<int>* test = &container;
  406. foreach (var item in *test)
  407. {
  408. Assert.True(test->Contains(item));
  409. seen[item] = seen[item] + 1;
  410. ++count;
  411. }
  412. }
  413. Assert.AreEqual(container.Length, count);
  414. for (int i = 0; i < n; i++)
  415. {
  416. Assert.AreEqual(1, seen[i], $"Incorrect item count {i}");
  417. }
  418. }
  419. }
  420. [Test]
  421. public void UnsafeListT_CustomAllocatorTest()
  422. {
  423. AllocatorManager.Initialize();
  424. var allocatorHelper = new AllocatorHelper<CustomAllocatorTests.CountingAllocator>(AllocatorManager.Persistent);
  425. ref var allocator = ref allocatorHelper.Allocator;
  426. allocator.Initialize();
  427. using (var container = new UnsafeList<byte>(1, allocator.Handle))
  428. {
  429. }
  430. Assert.IsTrue(allocator.WasUsed);
  431. allocator.Dispose();
  432. allocatorHelper.Dispose();
  433. AllocatorManager.Shutdown();
  434. }
  435. [BurstCompile]
  436. struct BurstedCustomAllocatorJob : IJob
  437. {
  438. [NativeDisableUnsafePtrRestriction]
  439. public unsafe CustomAllocatorTests.CountingAllocator* Allocator;
  440. public void Execute()
  441. {
  442. unsafe
  443. {
  444. using (var container = new UnsafeList<byte>(1, Allocator->Handle))
  445. {
  446. }
  447. }
  448. }
  449. }
  450. [Test]
  451. public unsafe void UnsafeListT_BurstedCustomAllocatorTest()
  452. {
  453. AllocatorManager.Initialize();
  454. var allocatorHelper = new AllocatorHelper<CustomAllocatorTests.CountingAllocator>(AllocatorManager.Persistent);
  455. ref var allocator = ref allocatorHelper.Allocator;
  456. allocator.Initialize();
  457. var allocatorPtr = (CustomAllocatorTests.CountingAllocator*)UnsafeUtility.AddressOf(ref allocator);
  458. unsafe
  459. {
  460. var handle = new BurstedCustomAllocatorJob { Allocator = allocatorPtr }.Schedule();
  461. handle.Complete();
  462. }
  463. Assert.IsTrue(allocator.WasUsed);
  464. allocator.Dispose();
  465. allocatorHelper.Dispose();
  466. AllocatorManager.Shutdown();
  467. }
  468. void IIndexableTest<T>(T container)
  469. where T : struct, IIndexable<int>
  470. {
  471. var length = container.Length;
  472. Assert.Throws<IndexOutOfRangeException>(() => container.ElementAt(-1));
  473. Assert.Throws<IndexOutOfRangeException>(() => container.ElementAt(container.Length));
  474. Assert.DoesNotThrow(() => { for (int i = 0, len = container.Length; i < len; ++i) { container.ElementAt(i) = 4; } });
  475. for (int i = 0, len = container.Length; i < len; ++i)
  476. {
  477. Assert.AreEqual(4, container.ElementAt(i));
  478. }
  479. }
  480. void INativeListTest<T>(T container)
  481. where T : struct, INativeList<int>
  482. {
  483. var length = container.Length;
  484. Assert.Throws<IndexOutOfRangeException>(() => container[-1] = 1);
  485. Assert.Throws<IndexOutOfRangeException>(() => container[container.Length] = 1);
  486. Assert.DoesNotThrow(() => { for (int i = 0, len = container.Length; i < len; ++i) { container[i] = 4; } });
  487. Assert.Throws<ArgumentOutOfRangeException>(() => container.Capacity = container.Length - 1);
  488. Assert.DoesNotThrow(() => container.Capacity = container.Length);
  489. Assert.DoesNotThrow(() => container.Capacity = container.Length + 1);
  490. for (int i = 0, len = container.Length; i < len; ++i)
  491. {
  492. Assert.AreEqual(4, container[i]);
  493. }
  494. }
  495. private unsafe void TestInterfaces<T>(T container)
  496. where T : struct, IIndexable<int>, INativeList<int>
  497. {
  498. container.Length = 4;
  499. Assert.DoesNotThrow(() => { for (int i = 0, len = container.Length; i < len; ++i) { container.ElementAt(i) = i; } });
  500. IIndexableTest(container);
  501. INativeListTest(container);
  502. }
  503. private unsafe void TestInterfacesDispose<T>(T container)
  504. where T : struct, IIndexable<int>, INativeList<int>, IDisposable
  505. {
  506. TestInterfaces(container);
  507. container.Dispose();
  508. }
  509. [Test]
  510. public unsafe void UnsafeListT_TestInterfaces() => TestInterfacesDispose(new UnsafeList<int>(1, CommonRwdAllocator.Handle));
  511. [Test]
  512. public unsafe void NativeList_TestInterfaces() => TestInterfacesDispose(new NativeList<int>(1, CommonRwdAllocator.Handle));
  513. [Test]
  514. public unsafe void FixedList32Bytes_TestInterfaces() => TestInterfaces(new FixedList32Bytes<int>());
  515. [Test]
  516. public unsafe void FixedList64Bytes_TestInterfaces() => TestInterfaces(new FixedList64Bytes<int>());
  517. [Test]
  518. public unsafe void FixedList128Bytes_TestInterfaces() => TestInterfaces(new FixedList128Bytes<int>());
  519. [Test]
  520. public unsafe void FixedList512Bytes_TestInterfaces() => TestInterfaces(new FixedList512Bytes<int>());
  521. [Test]
  522. public unsafe void FixedList4096Bytes_TestInterfaces() => TestInterfaces(new FixedList4096Bytes<int>());
  523. }