General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
1.0 KiB

#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{});