@@ -139,6 +139,26 @@ public void testBadUnboundedArenaSize() {
139
139
SegmentAllocator .newNativeArena ( -1 , MemorySession .global ());
140
140
}
141
141
142
+ @ Test (dataProvider = "allocators" , expectedExceptions = IllegalArgumentException .class )
143
+ public void testBadAllocationSize (SegmentAllocator allocator ) {
144
+ allocator .allocate (-1 );
145
+ }
146
+
147
+ @ Test (dataProvider = "allocators" , expectedExceptions = IllegalArgumentException .class )
148
+ public void testBadAllocationAlignZero (SegmentAllocator allocator ) {
149
+ allocator .allocate (1 , 0 );
150
+ }
151
+
152
+ @ Test (dataProvider = "allocators" , expectedExceptions = IllegalArgumentException .class )
153
+ public void testBadAllocationAlignNeg (SegmentAllocator allocator ) {
154
+ allocator .allocate (1 , -1 );
155
+ }
156
+
157
+ @ Test (dataProvider = "allocators" , expectedExceptions = IllegalArgumentException .class )
158
+ public void testBadAllocationAlignNotPowerTwo (SegmentAllocator allocator ) {
159
+ allocator .allocate (1 , 3 );
160
+ }
161
+
142
162
@ Test (dataProvider = "arrayAllocations" )
143
163
public <Z > void testArray (AllocationFactory allocationFactory , ValueLayout layout , AllocationFunction <Object , ValueLayout > allocationFunction , ToArrayHelper <Z > arrayHelper ) {
144
164
Z arr = arrayHelper .array ();
@@ -444,4 +464,13 @@ private MemoryAddress[] wrap(long[] ints) {
444
464
}
445
465
};
446
466
}
467
+
468
+ @ DataProvider (name = "allocators" )
469
+ static Object [][] allocators () {
470
+ return new Object [][] {
471
+ { SegmentAllocator .implicitAllocator () },
472
+ { SegmentAllocator .newNativeArena (MemorySession .global ()) },
473
+ { SegmentAllocator .prefixAllocator (MemorySegment .allocateNative (10 , MemorySession .global ())) },
474
+ };
475
+ }
447
476
}
0 commit comments