Skip to content

Commit 14ba3bd

Browse files
authored
std.testing: Fix expectEqualDeep formatted enum (#25960)
1 parent e4be00f commit 14ba3bd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/std/testing.zig

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
760760
.error_set,
761761
=> {
762762
if (actual != expected) {
763-
print("expected {}, found {}\n", .{ expected, actual });
763+
print("expected {any}, found {any}\n", .{ expected, actual });
764764
return error.TestExpectedEqual;
765765
}
766766
},
@@ -923,6 +923,18 @@ test "expectEqualDeep primitive type" {
923923
}.foo;
924924
try expectEqualDeep(fnType, fnType);
925925
}
926+
// enum with formatter
927+
{
928+
const TestEnum = enum {
929+
a,
930+
b,
931+
932+
pub fn format(self: @This(), writer: *std.Io.Writer) !void {
933+
try writer.writeAll(@tagName(self));
934+
}
935+
};
936+
try expectEqualDeep(TestEnum.b, TestEnum.b);
937+
}
926938
}
927939

928940
test "expectEqualDeep pointer" {

0 commit comments

Comments
 (0)