std.testing: Fix expectEqualDeep formatted enum (#25960)

This commit is contained in:
Nir Lahad 2025-11-25 15:39:07 +02:00 committed by GitHub
parent e4be00f949
commit 14ba3bd9a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -760,7 +760,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
.error_set,
=> {
if (actual != expected) {
print("expected {}, found {}\n", .{ expected, actual });
print("expected {any}, found {any}\n", .{ expected, actual });
return error.TestExpectedEqual;
}
},
@ -923,6 +923,18 @@ test "expectEqualDeep primitive type" {
}.foo;
try expectEqualDeep(fnType, fnType);
}
// enum with formatter
{
const TestEnum = enum {
a,
b,
pub fn format(self: @This(), writer: *std.Io.Writer) !void {
try writer.writeAll(@tagName(self));
}
};
try expectEqualDeep(TestEnum.b, TestEnum.b);
}
}
test "expectEqualDeep pointer" {