It may be useful to flip the arguments to std.testing.expectEqual. Right now, the expected value is the first formal parameter and the actual value is the second formal parameter.
When working with optional types, this makes testing via expectEqual impossible:
const std = @import("std");
pub fn expectEqual(actual: var, expected: @TypeOf(actual)) void {}
pub fn main() void {
const x: ?u8 = 1;
expectEqual(x, 1);
// Doesn't work as the type of the expected value is comptime_int
// std.testing.expectEqual(1, x);
const y: ?u8 = null;
expectEqual(x, null);
// Doesn't work as the type of the expected value is (null)
// std.testing.expectEqual(null, y);
}
But this may also be a very minor edge case.
It may be useful to flip the arguments to
std.testing.expectEqual. Right now, the expected value is the first formal parameter and the actual value is the second formal parameter.When working with optional types, this makes testing via
expectEqualimpossible:But this may also be a very minor edge case.