Skip to content

std.testing: Fully absorb expectEqualBytes into expectEqualSlices #13816

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

Merged
merged 1 commit into from
Dec 9, 2022

Conversation

squeek502
Copy link
Collaborator

@squeek502 squeek502 commented Dec 8, 2022

For u8, expectEqualSlices works as expectEqualBytes did before. 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.

This should address all the TODO comments that were in expectEqualSlices.


The most dramatic improvement is when the slice lengths differ. Here's an example with u32 as the type:

Before:

Test [6/11] test_2... slice lengths differ. expected 2030, found 1170
Test [6/11] test_2... FAIL (TestExpectedEqual)
C:\Users\Ryan\Programming\Zig\zig\lib\std\testing.zig:296:9: 0x7ff6d6973e70 in expectEqualSlices__anon_2684 (test.exe.obj)
        return error.TestExpectedEqual;
        ^
C:\Users\Ryan\Programming\Zig\zig\lib\std\testing.zig:326:5: 0x7ff6d6974212 in test_2 (test.exe.obj)
    try expectEqualSlices(u32, &a, &b);
    ^

After:
expectEqualBytes5

@squeek502 squeek502 force-pushed the expectEqualSlices-hungers branch from 87c490d to db616b4 Compare December 8, 2022 21:05
- 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 squeek502 force-pushed the expectEqualSlices-hungers branch from db616b4 to fb8d065 Compare December 9, 2022 04:52
@andrewrk andrewrk enabled auto-merge (rebase) December 9, 2022 08:06
@andrewrk
Copy link
Member

andrewrk commented Dec 9, 2022

Thanks for giving std.testing some much-needed love!

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