File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -32,4 +32,29 @@ is_aligned_allocation(gc_object_t obj)
3232 return ((* magic_ptr & ALIGNED_ALLOC_MAGIC_MASK ) == ALIGNED_ALLOC_MAGIC_VALUE );
3333}
3434
35- /* Tests will be added incrementally */
35+ /* Test: Normal allocation still works (regression) */
36+ static void
37+ test_normal_alloc_basic (void * * state )
38+ {
39+ mem_allocator_t allocator ;
40+ char heap_buf [64 * 1024 ];
41+ void * ptr ;
42+
43+ allocator = mem_allocator_create (heap_buf , sizeof (heap_buf ));
44+ assert_non_null (allocator );
45+
46+ /* Normal allocation should still work */
47+ ptr = mem_allocator_malloc (allocator , 128 );
48+ assert_non_null (ptr );
49+
50+ /* Should be 8-byte aligned */
51+ assert_true (is_aligned (ptr , 8 ));
52+
53+ /* Should NOT be marked as aligned allocation */
54+ assert_false (is_aligned_allocation (ptr ));
55+
56+ /* Free should work */
57+ mem_allocator_free (allocator , ptr );
58+
59+ mem_allocator_destroy (allocator );
60+ }
Original file line number Diff line number Diff line change 1616main (void )
1717{
1818 const struct CMUnitTest tests [] = {
19- /* Tests will be added incrementally */
19+ cmocka_unit_test ( test_normal_alloc_basic ),
2020 };
2121
2222 return cmocka_run_group_tests (tests , NULL , NULL );
You can’t perform that action at this time.
0 commit comments