glfw: correctly test Monitor implementation

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-07-16 16:56:58 -07:00
parent 10eb3b5680
commit 8ade50719d
2 changed files with 6 additions and 4 deletions

View file

@ -27,10 +27,10 @@ pub fn getAll(allocator: *mem.Allocator) ![]Monitor {
var count: c_int = 0;
const monitors = c.glfwGetMonitors(&count);
const slice = allocator.alloc(Monitor, count);
var i = 0;
const slice = try allocator.alloc(Monitor, @intCast(usize, count));
var i: usize = 0;
while (i < count) : (i += 1) {
slice[i] = Monitor{ .handle = monitors[i] };
slice[i] = Monitor{ .handle = monitors[i].? };
}
return slice;
}
@ -50,7 +50,8 @@ pub fn getPrimary() !?Monitor {
if (handle == null) {
return null;
}
return Monitor{ .handle = handle };
try getError();
return Monitor{ .handle = handle.? };
}
test "getAll" {

View file

@ -143,5 +143,6 @@ test "version" {
}
test "basic" {
_ = Monitor;
basicTest() catch unreachable;
}