#include "gp/utils/pointers.hpp"
|
|
#include "gp/utils/allocators/arena.hpp"
|
|
#include "test_scaffold.h"
|
|
#include "allocator.hpp"
|
|
#include <memory>
|
|
|
|
|
|
struct arena_test : public test_scaffold {
|
|
uint32_t seed;
|
|
|
|
arena_test() {
|
|
name = __FILE__ ":1";
|
|
}
|
|
|
|
virtual int run() {
|
|
int return_val = 0;
|
|
std::unique_ptr<gp::array<char, 4096*4>> store = std::make_unique<gp::array<char, 4096*4>>();
|
|
gp::arena alloc{&*store->begin(), store->size()};
|
|
auto v = gp::unique_ptr<uint64_t>::make(alloc, 1024);
|
|
gp::arena alloc2{alloc, 1024};
|
|
gp::arena alloc3{};
|
|
{
|
|
auto v2 = gp::unique_ptr<uint64_t>::make(alloc2, 1024);
|
|
void* some_memory = alloc2.allocate(128);
|
|
if(!some_memory) return_val++;
|
|
if(alloc2.deallocate(nullptr)) return_val++;
|
|
}
|
|
{
|
|
if(alloc3.allocate(4)) return_val++;
|
|
if(alloc3.deallocate(nullptr)) return_val++;
|
|
}
|
|
alloc2.reset();
|
|
return return_val;
|
|
}
|
|
};
|
|
|
|
append_test dummy_8djbvs543(new arena_test{});
|