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

Compare strings instead of byte slices in tests #152

Closed
robinkrahl opened this issue Apr 15, 2021 · 2 comments
Closed

Compare strings instead of byte slices in tests #152

robinkrahl opened this issue Apr 15, 2021 · 2 comments
Assignees

Comments

@robinkrahl
Copy link
Collaborator

In some tests – for example status::not_found_raw –, we compare byte slices with assert_eq!. This results in an error message that is very hard to read, see for example this log. Creating a string with String::from_utf8_lossy and comparing it to a string value would be functionally identical but much easier to read.

@robinkrahl robinkrahl self-assigned this Apr 15, 2021
@robinkrahl
Copy link
Collaborator Author

Alternatively, the string representation could be used in the assert message.

@d-e-s-o
Copy link
Owner

d-e-s-o commented Apr 16, 2021

Alternatively, the string representation could be used in the assert message.

Sounds good to me, let's do that.

robinkrahl added a commit to robinkrahl/nitrocli that referenced this issue Apr 16, 2021
Some of our tests compare byte slices which is very hard to debug if the
assertion fails.  This patch adds assertion messages containing the
(lossy) string representation of the byte slice to make it easier to
debug errors.

Fixes d-e-s-o#152.
robinkrahl added a commit to robinkrahl/nitrocli that referenced this issue Apr 16, 2021
Some of our tests compare byte slices which is very hard to debug if the
assertion fails.  This patch adds assertion messages containing the
(lossy) string representation of the byte slice to make it easier to
debug errors.

Fixes d-e-s-o#152.
d-e-s-o pushed a commit that referenced this issue May 9, 2021
Some of our tests compare byte slices and are very hard to debug if the
assertion fails due to they way these slices are printed. This patch
adds assertion messages containing the (lossy) string representation of
the byte slice to make it easier to debug errors.

Fixes #152
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

2 participants