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
Print warning when we cannot print good diff #104
base: main
Are you sure you want to change the base?
Conversation
@lemolatoon Oh, that's quite tricky - even if a diff is shown, these differences could be hidden in the output. :-/ No Diff CaseThe warning is good, but let's try to offer more - why not at least fall back to the default presentation AFTER the warning? General CaseI wonder if we should try to detect "invisible" differences and implement more general fallbacks? |
@colin-kiegel Thank you for replying. Let me comfirm what you suggested. No Diff CaseSo you mean Asking (
General CaseIn another case, such as... use pretty_assertions::assert_eq;
fn main() {
assert_eq!("a\n", "ab\r\n");
} As you pointed out, on current implementation, we cannot detect and print warning on this type. What I am going to doI am going to fix these points. |
@lemolatoon That's only part of what I meant - first let's keep the second part, but not as a question:
Then we could fallback to showing the debug-string of left and right, like the original "not pretty"
|
Now by the commit I just did. It should be ok. use pretty_assertions::assert_eq;
fn main() {
assert_eq!("Foo\n", "Foo\r\n")
}
|
You might want to steal some code from |
@mitsuhiko Nice, thank you!
I also like the way you both print the original left / right output AND the difference. It seems worthwile to also copy this behaviour - so far Off-Topic: Do you see any other areas where either PS: @tommilligan What's your thought on all of this? |
@colin-kiegel similar-asserts pretty much only exists because of the performance issues i with with this crate in the past on large diffs and I already had similar in my dependency tree for insta. But since pretty-assertions is used in a lot of places I am exposed to it :) I personally believe that at this point similar-asserts is the better crate, but it has much lower adoption and in the most ideal of cases they would just become the same thing. |
Ref #100
If left and right are not equal, but we cannot print any diff, then make sure to print warning instead.
example: