Add tracking allocator to test runner. #1809

This commit is contained in:
Christoffer Lerno
2025-02-09 03:10:35 +01:00
parent ce06de4b18
commit 63f619e5b6
16 changed files with 121 additions and 37 deletions

View File

@@ -6,6 +6,7 @@ def IntList = LinkedList(<int>);
fn void test_push_front()
{
IntList list;
defer list.free();
list.push_front(23);
assert(list.len() == 1);
assert(list.first()!! == 23);
@@ -14,11 +15,13 @@ fn void test_push_front()
assert(list.len() == 2);
assert(list.last()!! == 23);
assert(list.first()!! == 55);
}
fn void test_push()
{
IntList list;
defer list.free();
list.push(23);
assert(list.len() == 1);
assert(list.first()!! == 23);
@@ -32,6 +35,7 @@ fn void test_push()
fn void test_get()
{
IntList list;
defer list.free();
list.push(23);
list.push(55);
list.push(-3);
@@ -43,6 +47,7 @@ fn void test_get()
fn void test_insert()
{
IntList list;
defer list.free();
list.push(-3);
list.push(55);
list.push(23);
@@ -62,6 +67,7 @@ fn void test_insert()
fn void test_set()
{
IntList list;
defer list.free();
list.push(-3);
list.push(55);
list.push(23);
@@ -74,6 +80,7 @@ fn void test_set()
fn void test_remove_at()
{
IntList list;
defer list.free();
for (int i = 0; i < 10; i++) list.push(i);
list.remove_at(0);
list.remove_at(1);
@@ -88,6 +95,7 @@ fn void test_remove_at()
fn void test_remove()
{
IntList list;
defer list.free();
list.push(2);
for (int i = 0; i < 10; i++) list.push(5);
list.push(2);
@@ -98,6 +106,7 @@ fn void test_remove()
fn void test_remove_first_match()
{
IntList list;
defer list.free();
list.push(23);
list.push(55);
list.push(-3);
@@ -126,6 +135,7 @@ fn void test_remove_first_match()
fn void test_remove_last_match()
{
IntList list;
defer list.free();
list.push(23);
list.push(55);
list.push(-3);
@@ -154,6 +164,7 @@ fn void test_remove_last_match()
fn void test_pop()
{
IntList list;
defer list.free();
list.push(23);
list.push(55);
list.push(-3);
@@ -178,6 +189,7 @@ fn void test_pop()
fn void test_remove_last()
{
IntList list;
defer list.free();
list.push(23);
list.push(55);
list.push(-3);
@@ -202,6 +214,7 @@ fn void test_remove_last()
fn void test_remove_first()
{
IntList list;
defer list.free();
list.push(23);
list.push(55);
list.push(-3);

View File

@@ -13,6 +13,8 @@ def OveralignList = List(<Overalign>);
fn void overaligned_type()
{
OveralignList l;
defer l.free();
Overalign y;
for (int i = 0; i < 1000; i++) l.push(y);
assert((usz)l.get_ref(2) - (usz)l.get_ref(1) == Overalign.sizeof);
@@ -22,6 +24,8 @@ fn void overaligned_type()
fn void delete_contains_index()
{
IntList test;
defer test.free();
test.add_array({ 1, 2 });
assert(test.contains(1));
assert(test.contains(2));
@@ -51,6 +55,7 @@ fn void delete_contains_index()
fn void compact()
{
PtrList test;
defer test.free();
test.add_array({ null, &test });
assert(test.compact_count() == 1);
test.push(null);
@@ -64,6 +69,8 @@ fn void compact()
fn void reverse()
{
IntList test;
defer test.free();
test.reverse();
test.add_array({ 1, 2 });
test.push(3);
@@ -79,6 +86,7 @@ fn void reverse()
fn void remove_if()
{
IntList test;
defer test.free();
usz removed;
test.add_array({ 1, 11, 2, 10, 20 });
@@ -96,6 +104,7 @@ fn void remove_if()
fn void init_with_array()
{
IntList foo;
defer foo.free();
foo.new_init_with_array({ 1, 2, 3});
assert(foo.len() == 3);
assert(foo[2] == 3);
@@ -112,6 +121,7 @@ fn void init_with_temp_array()
fn void remove_using_test()
{
IntList test;
defer test.free();
usz removed;
test.add_array({ 1, 11, 2, 10, 20 });
@@ -129,6 +139,7 @@ fn void remove_using_test()
fn void retain_if()
{
IntList test;
defer test.free();
usz removed;
test.add_array({ 1, 11, 2, 10, 20 });
@@ -146,6 +157,7 @@ fn void retain_if()
fn void retain_using_test()
{
IntList test;
defer test.free();
usz removed;
test.add_array({ 1, 11, 2, 10, 20 });

View File

@@ -4,6 +4,8 @@ import std::collections::object;
fn void test_general()
{
Object* root = object::new_obj(allocator::heap());
defer root.free();
root.set("foo", 1);
root.set("bar", "baz");
assert(root.get_int("foo")!! == 1);

View File

@@ -7,6 +7,8 @@ def Queue = PriorityQueue(<int>);
fn void priorityqueue()
{
Queue q;
defer q.free();
assert(q.is_empty());
q.push(1);
@@ -35,6 +37,7 @@ def QueueMax = PriorityQueueMax(<int>);
fn void priorityqueue_max()
{
QueueMax q;
defer q.free();
assert(q.is_empty());
q.push(1);