Basic test implementation
This commit is contained in:
@@ -46,20 +46,23 @@ test "valid road nodes" {
|
||||
defer _ = gpa.deinit();
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
const start: Node = .init(34, .{500, 500});
|
||||
const start: Node = .init(34, .{.x = 500, .y = 500});
|
||||
const start_ptr = try allocator.create(Node);
|
||||
defer {
|
||||
start_ptr.*.deinit(allocator);
|
||||
allocator.destroy(start_ptr);
|
||||
}
|
||||
start_ptr.* = start;
|
||||
|
||||
const end: Node = .init(227, .{600, 500});
|
||||
const end: Node = .init(227, .{.x = 600, .y = 500});
|
||||
const end_ptr = try allocator.create(Node);
|
||||
defer {
|
||||
end_ptr.*.deinit(allocator);
|
||||
allocator.destroy(end_ptr);
|
||||
}
|
||||
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);
|
||||
}
|
||||
@@ -4,9 +4,6 @@ const rl = @import("raylib");
|
||||
const c = @import("constants.zig");
|
||||
const Simulator = @import("simulator.zig").Simulator;
|
||||
|
||||
// TODO PLANS
|
||||
// Additionally add more robust error and test handling
|
||||
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const allocator = init.gpa;
|
||||
|
||||
|
||||
3
src/test.zig
Normal file
3
src/test.zig
Normal file
@@ -0,0 +1,3 @@
|
||||
test {
|
||||
_ = @import("infrastructure/road.zig");
|
||||
}
|
||||
Reference in New Issue
Block a user