diff options
| author | travisstaloch <twostepted@gmail.com> | 2023-09-23 13:25:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-23 20:25:57 +0000 |
| commit | 759b0fe00a5c58d498f758dcafe1abb20f6c40b6 (patch) | |
| tree | 02844d13cc919a34b497f0df61c4a8e4d4b4e67b /lib/std/testing.zig | |
| parent | 80ae27bc844ce7fe18bc686ce4befa24ab0f86bb (diff) | |
| download | zig-759b0fe00a5c58d498f758dcafe1abb20f6c40b6.tar.gz zig-759b0fe00a5c58d498f758dcafe1abb20f6c40b6.zip | |
std.testing: expectEqualDeep() - support self-referential structs
Diffstat (limited to 'lib/std/testing.zig')
| -rw-r--r-- | lib/std/testing.zig | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 17ac0d4b04..4dda8a0d0d 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -691,8 +691,9 @@ pub fn expectStringEndsWith(actual: []const u8, expected_ends_with: []const u8) /// Container types(like Array/Slice/Vector) deeply equal when their corresponding elements are deeply equal. /// Pointer values are deeply equal if values they point to are deeply equal. /// -/// Note: Self-referential structs are not supported (e.g. things like std.SinglyLinkedList) -pub fn expectEqualDeep(expected: anytype, actual: @TypeOf(expected)) !void { +/// Note: Self-referential structs are supported (e.g. things like std.SinglyLinkedList) +/// but may cause infinite recursion or stack overflow when a container has a pointer to itself. +pub fn expectEqualDeep(expected: anytype, actual: @TypeOf(expected)) error{TestExpectedEqual}!void { switch (@typeInfo(@TypeOf(actual))) { .NoReturn, .Opaque, |
