use testing.expectError

This commit is contained in:
psznm 2025-11-24 21:00:50 +01:00
parent cdb85b2c87
commit a79ccf9679

View file

@ -14,11 +14,7 @@ fn test_kill_nonexistent() !void {
// MacOS maximum pid appears to be 99999 and not configurable. // MacOS maximum pid appears to be 99999 and not configurable.
// Others are unknown thus not tested. // Others are unknown thus not tested.
const impossible_pid: posix.pid_t = 1_999_999_999; const impossible_pid: posix.pid_t = 1_999_999_999;
posix.kill(impossible_pid, .INVAL) catch |err| switch (err) { try std.testing.expectError(posix.KillError.ProcessNotFound, posix.kill(impossible_pid, .INVAL));
posix.KillError.ProcessNotFound => return,
else => return err,
};
return error.ProcessShouldHaveNotBeenFound;
} }
fn test_kill_zero_self_should_succeed() !void { fn test_kill_zero_self_should_succeed() !void {