Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.testing: Improve expectEqualBytes for large inputs and make expectEqualSlices use it #13723

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

squeek502
Copy link
Collaborator

@squeek502 squeek502 commented Dec 1, 2022

Follow up to #13720.

expectEqualBytes will now truncate the hexdump of each input to a maximum window of 256 bytes, which makes it safe to use for arbitrarily large inputs. Therefore, it can be used in expectEqualSlices when the type is u8.

If the input needs to be truncated, then the printed section of each will start slightly before the first difference.

Here's an example of what it looks like when the inputs are truncated:

expectEqualBytes3

…tEqualSlices use it

`expectEqualBytes` will now truncate the hexdump of each input to a maximum window of 256 bytes, which makes it safe to use for arbitrarily large inputs. Therefore, it can be used in `expectEqualSlices` when the type is u8.
@andrewrk andrewrk enabled auto-merge (rebase) December 1, 2022 02:39
@andrewrk andrewrk merged commit c37afa2 into ziglang:master Dec 1, 2022
squeek502 added a commit to squeek502/zig that referenced this pull request Dec 8, 2022
- In ziglang#13720, expectEqualBytes was added as a standalone function
- In ziglang#13723, expectEqualSlices was made to use expectEqualBytes when the type was u8
- In this commit, expectEqualSlices has fully absorbed expectEqualBytes, and expectEqualBytes itself has been removed

For non-`u8` types, expectEqualSlices will now work similarly to expectEqualBytes (highlighting diffs in red), but will use a full line for each index and therefore will only print a maximum of 16 indexes.
squeek502 added a commit to squeek502/zig that referenced this pull request Dec 8, 2022
- In ziglang#13720, expectEqualBytes was added as a standalone function
- In ziglang#13723, expectEqualSlices was made to use expectEqualBytes when the type was u8
- In this commit, expectEqualSlices has fully absorbed expectEqualBytes, and expectEqualBytes itself has been removed

For non-`u8` types, expectEqualSlices will now work similarly to expectEqualBytes (highlighting diffs in red), but will use a full line for each index and therefore will only print a maximum of 16 indexes.
squeek502 added a commit to squeek502/zig that referenced this pull request Dec 9, 2022
- In ziglang#13720, expectEqualBytes was added as a standalone function
- In ziglang#13723, expectEqualSlices was made to use expectEqualBytes when the type was u8
- In this commit, expectEqualSlices has fully absorbed expectEqualBytes, and expectEqualBytes itself has been removed

For non-`u8` types, expectEqualSlices will now work similarly to expectEqualBytes (highlighting diffs in red), but will use a full line for each index and therefore will only print a maximum of 16 indexes.
andrewrk pushed a commit that referenced this pull request Dec 9, 2022
- In #13720, expectEqualBytes was added as a standalone function
- In #13723, expectEqualSlices was made to use expectEqualBytes when the type was u8
- In this commit, expectEqualSlices has fully absorbed expectEqualBytes, and expectEqualBytes itself has been removed

For non-`u8` types, expectEqualSlices will now work similarly to expectEqualBytes (highlighting diffs in red), but will use a full line for each index and therefore will only print a maximum of 16 indexes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants