Implemented a few basic tests and ideas for future ones

This commit is contained in:
2026-04-29 13:18:27 +02:00
parent d7c7320443
commit 750bad7f83
6 changed files with 84 additions and 7 deletions

View File

@@ -73,4 +73,32 @@ pub const NodeManager = struct {
self.nodes.clearRetainingCapacity();
self.next_id = 0;
}
};
};
const expect = std.testing.expect;
test "id tracking" {
var gpa: std.heap.DebugAllocator(.{}) = .init;
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var node_man: NodeManager = .init();
defer node_man.deinit(allocator);
const n = 5;
for (0..n) |_| {
const node: Node = .init(node_man.getNextID(), Vector2 {
.x = 500,
.y = 500,
});
const node_ptr = try allocator.create(Node);
node_ptr.* = node;
try node_man.nodes.append(allocator, node_ptr);
}
try expect(node_man.next_id == n);
try expect(node_man.nodes.items.len == n);
}
// TODO tests
// force resize pointer test