borrow allocator implementation

This commit is contained in:
2025-10-08 22:16:31 +02:00
parent 6ffbc05f52
commit a20833f4ee
3 changed files with 120 additions and 13 deletions
+14
View File
@@ -0,0 +1,14 @@
#include <criterion/criterion.h>
#include "allocator.h"
#define EXPECT 5
Test(borrow_allocator, test) {
borrow_allocator_t balloc = borrow_allocator_create();
int *ptr = borrow_allocator_alloc(&balloc, sizeof(int));
*ptr = EXPECT;
cr_assert_eq(*ptr, EXPECT);
cr_assert_eq(1, borrow_allocator_count_allocations(&balloc));
borrow_allocator_reset(&balloc);
cr_assert_eq(0, borrow_allocator_count_allocations(&balloc));
borrow_allocator_assert_all_freed(&balloc);
}