public void NativeMultiHashMap_ValueIterator() { var hashMap = new NativeMultiHashMap <int, int> (1, Allocator.Temp); hashMap.Add(5, 0); hashMap.Add(5, 1); hashMap.Add(5, 2); var list = new NativeList <int>(Allocator.TempJob); GCAllocRecorder.ValidateNoGCAllocs(() => { list.Clear(); foreach (var value in hashMap.GetValuesForKey(5)) { list.Add(value); } }); list.Sort(); Assert.AreEqual(list.ToArray(), new int[] { 0, 1, 2 }); foreach (var value in hashMap.GetValuesForKey(6)) { Assert.Fail(); } list.Dispose(); hashMap.Dispose(); }
public void TestNoAlloc() { GCAllocRecorder.ValidateNoGCAllocs(() => { var p = new int(); }); }
public void TestAlloc() { Assert.Throws <AssertionException>(() => { GCAllocRecorder.ValidateNoGCAllocs(() => { var p = new int[5]; }); }); }
public void NativeMultiHashMap_RemoveKeyValueDoesntDeallocate() { var hashMap = new NativeMultiHashMap <int, int> (1, Allocator.Temp); hashMap.Add(5, 1); hashMap.Remove(5, 5); GCAllocRecorder.ValidateNoGCAllocs(() => { hashMap.Remove(5, 1); }); hashMap.Dispose(); }
public void TestBeginEnd() { GCAllocRecorder.BeginNoGCAlloc(); GCAllocRecorder.EndNoGCAlloc(); }