| 1 |
@system unittest |
| 2 |
{ |
| 3 |
import std.experimental.allocator.building_blocks.fallback_allocator; |
| 4 |
|
| 5 |
import std.experimental.allocator.building_blocks.region : Region; |
| 6 |
import std.experimental.allocator.gc_allocator : GCAllocator; |
| 7 |
import std.typecons : Ternary; |
| 8 |
auto a = fallbackAllocator(Region!GCAllocator(1024), GCAllocator.instance); |
| 9 |
auto b1 = a.allocate(1020); |
| 10 |
assert(b1.length == 1020); |
| 11 |
assert(a.primary.owns(b1) == Ternary.yes); |
| 12 |
auto b2 = a.allocate(10); |
| 13 |
assert(b2.length == 10); |
| 14 |
assert(a.primary.owns(b2) == Ternary.no); |
| 15 |
} |
| 16 |
|