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

Hex/Binary diff and formatting for number collections #105

Open
XAMPPRocky opened this issue Feb 25, 2023 · 3 comments
Open

Hex/Binary diff and formatting for number collections #105

XAMPPRocky opened this issue Feb 25, 2023 · 3 comments

Comments

@XAMPPRocky
Copy link

Hello, I really like using this crate for my tests as it makes it a lot easier to spot which byte has changed or regressed from a change. It would be nice if the crate supported hex and/or binary formatting for collections of numbers (e.g. &[u8]), so that you could see much more easily on the bit level what changed about a number, as currently see the difference between two base-10 numbers isn't that useful for me when comparing binary serialisation output.

@tommilligan
Copy link
Collaborator

Hey, thanks for your feedback. Custom formatting is a widely requested feature - it's good to have the additional data points of binary/hex output format.

I have some ideas on how this could be supported with an opt-in feature, I will keep you posted if I implement them.

@XAMPPRocky
Copy link
Author

XAMPPRocky commented Mar 16, 2023

FWIW since it is a macro, you could always add an additional argument to the macro that accepts a Settings type, this would keep it being compatible with std::assert_* but allow people to opt in on a case by case basis, as at least right now I don't think I would want it to be something that's crate wide enabled or disabled.

assert_eq!([0x80, 0x70], [0x70, 0x80], "binary output mismatched", pretty_assertions::Settings::hex());

@xpe
Copy link

xpe commented Sep 7, 2023

@tommilligan I'm also interested in this feature. How much more discussion / design do you think is needed? Do you think you might be open to a PR at some point?

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

No branches or pull requests

3 participants