mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add Implicit @pool for Each Unit Test Invocation (#2654)
* Add Implicit `@pool` for Each Unit Test Invocation
This commit is contained in:
26
test/unit/stdlib/runtime_test.c3
Normal file
26
test/unit/stdlib/runtime_test.c3
Normal file
@@ -0,0 +1,26 @@
|
||||
module runtime_test_tests @test;
|
||||
|
||||
import std::core::runtime @public;
|
||||
import std::core::mem::allocator @public;
|
||||
import std::math::random;
|
||||
|
||||
|
||||
fn void tmem_shouldnt_leak_if_no_pool()
|
||||
{
|
||||
for (usz i = 0; i < 256; i++)
|
||||
{
|
||||
char[] my_arr = mem::talloc_array(char, 1024);
|
||||
my_arr[..] = (char[*]){ [0..1023] = 0xA5 }[..];
|
||||
}
|
||||
}
|
||||
|
||||
fn void ensure_leak_check_works()
|
||||
{
|
||||
if (!(runtime::test_context.check_leaks)) return;
|
||||
|
||||
char[] my_arr = mem::alloc_array(char, 1024);
|
||||
test::@check(((TrackingAllocator*)allocator::thread_allocator).has_leaks());
|
||||
|
||||
mem::free(my_arr);
|
||||
test::@check(!((TrackingAllocator*)allocator::thread_allocator).has_leaks());
|
||||
}
|
||||
Reference in New Issue
Block a user