authorgravatar for twostepted@gmail.comTravis Staloch <twostepted@gmail.com> 2023-09-23 13:25:57-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-09-23 20:25:57+00:00
log759b0fe00a5c58d498f758dcafe1abb20f6c40b6
tree02844d13cc919a34b497f0df61c4a8e4d4b4e67b
parent80ae27bc844ce7fe18bc686ce4befa24ab0f86bb
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

std.testing: expectEqualDeep() - support self-referential structs


1 files changed, 3 insertions(+), 2 deletions(-)

lib/std/testing.zig+3-2
...@@ -691,8 +691,9 @@ pub fn expectStringEndsWith(actual: []const u8, expected_ends_with: []const u8)...@@ -691,8 +691,9 @@ pub fn expectStringEndsWith(actual: []const u8, expected_ends_with: []const u8)
691/// Container types(like Array/Slice/Vector) deeply equal when their corresponding elements are deeply equal.691/// Container types(like Array/Slice/Vector) deeply equal when their corresponding elements are deeply equal.
692/// Pointer values are deeply equal if values they point to are deeply equal.692/// Pointer values are deeply equal if values they point to are deeply equal.
693///693///
694/// Note: Self-referential structs are not supported (e.g. things like std.SinglyLinkedList)694/// Note: Self-referential structs are supported (e.g. things like std.SinglyLinkedList)
695pub fn expectEqualDeep(expected: anytype, actual: @TypeOf(expected)) !void {695/// but may cause infinite recursion or stack overflow when a container has a pointer to itself.
696pub fn expectEqualDeep(expected: anytype, actual: @TypeOf(expected)) error{TestExpectedEqual}!void {
696 switch (@typeInfo(@TypeOf(actual))) {697 switch (@typeInfo(@TypeOf(actual))) {
697 .NoReturn,698 .NoReturn,
698 .Opaque,699 .Opaque,