Skip to content

Commit 37f3bee

Browse files
committed
added test b2AllocateArenaItem_WhenEnoughCapacity
1 parent 2073033 commit 37f3bee

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test/Box2D.NET.Test/B2ArenaAllocatorTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Threading;
22
using System.Threading.Tasks;
33
using NUnit.Framework;
4+
using static Box2D.NET.B2ArenaAllocators;
45

56
namespace Box2D.NET.Test;
67

@@ -115,4 +116,21 @@ public void GetOrCreateFor_ShouldBeThreadSafe_WhenCalledConcurrently()
115116

116117
Assert.That(arena.Count, Is.EqualTo(10));
117118
}
119+
120+
121+
[Test]
122+
public void b2AllocateArenaItem_WhenEnoughCapacity()
123+
{
124+
var arena = new B2ArenaAllocator(10);
125+
var result = b2AllocateArenaItem<int>(arena, 16, "test");
126+
var alloc = arena.GetOrCreateFor<int>();
127+
128+
Assert.That(result.Count, Is.EqualTo(32));
129+
Assert.That(result.Offset, Is.EqualTo(0));
130+
131+
Assert.That(alloc.index, Is.EqualTo(0));
132+
Assert.That(alloc.allocation, Is.EqualTo(32));
133+
Assert.That(alloc.entries.count, Is.EqualTo(1));
134+
Assert.That(alloc.entries.data[0].usedMalloc, Is.True);
135+
}
118136
}

0 commit comments

Comments
 (0)