Playing around with testing (unsuccessfully)

This commit is contained in:
2026-04-29 10:17:48 +02:00
parent fc67fe3d7e
commit be06634232
4 changed files with 31 additions and 5 deletions

View File

@@ -1,4 +1,6 @@
const std = @import("std");
const rl = @import("raylib");
const expect = std.testing.expect;
const c = @import("../constants.zig");
const Node = @import("node.zig").Node;
@@ -37,4 +39,27 @@ pub const Road = struct {
pub fn draw(self: *const Road) void {
rl.drawLineEx(self.nodes[0].*.pos, self.nodes[1].*.pos, c.ROAD_SIZE, c.ROAD_COLOUR);
}
};
};
test "valid road nodes" {
var gpa: std.heap.DebugAllocator(.{}) = .init;
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const start: Node = .init(34, .{500, 500});
const start_ptr = try allocator.create(Node);
start_ptr.* = start;
const end: Node = .init(227, .{600, 500});
const end_ptr = try allocator.create(Node);
end_ptr.* = end;
const road: Road = .init(11, start_ptr, end_ptr);
try expect(road.nodes[0].id == 34 and road.nodes[1].id == 227);
}
test "false" {
const truth = false;
try expect(truth);
}