summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/alloc.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/alloc.c b/tests/alloc.c
index 91b1b43..9e6e892 100644
--- a/tests/alloc.c
+++ b/tests/alloc.c
@@ -8,7 +8,7 @@
int main(void) {
// Check sizeof_flex()
struct flexible {
- alignas(64) int foo;
+ alignas(64) int foo[8];
int bar[];
};
bfs_verify(sizeof_flex(struct flexible, bar, 0) >= sizeof(struct flexible));
@@ -20,5 +20,17 @@ int main(void) {
// Doesn't happen in typical ABIs
bfs_verify(flex_size(8, 16, 4, 4, 1) == 16);
+ // varena tests
+ struct varena varena;
+ VARENA_INIT(&varena, struct flexible, bar);
+
+ for (size_t i = 0; i < 256; ++i) {
+ bfs_verify(varena_alloc(&varena, i));
+ struct arena *arena = &varena.arenas[varena.narenas - 1];
+ bfs_verify(arena->size >= sizeof_flex(struct flexible, bar, i));
+ }
+
+ varena_destroy(&varena);
+
return EXIT_SUCCESS;
}