File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System . Threading ;
22using System . Threading . Tasks ;
33using NUnit . Framework ;
4+ using static Box2D . NET . B2ArenaAllocators ;
45
56namespace 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}
You can’t perform that action at this time.
0 commit comments