-
Notifications
You must be signed in to change notification settings - Fork 268
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
Use constants in bytes.rs test code #247
Conversation
src/bytes.rs
Outdated
for &cap in &[1024, 1025, 1100, 2000, 2047] { | ||
assert_eq!(1, original_capacity_to_repr(cap)); | ||
} | ||
for i in 0..32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I see where are coming from.
If I am reading it right, this change seems to restrict the numbers being tested to powers of two and powers of 2 + 1. Before, there were more types of numbers being tested.
What are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You read it right.
I think there is no right answer on deciding test coverage of the function.
Would it be enough if I add 0, 1000, 1100, 2000, 2047?
Or we can consider testing some random-generated numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right... there is no right answer :) There also is the risk of "reimplementing" the original algorithm and introducing bugs in the test.
If you want to pursue the PR, I would merge it w/ the added numbers you listed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the changed test code!
I tried to use MIN_ORIGINAL_CAPACITY_WIDTH
for the added numbers, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Got a failing test! |
Oh, it's my first cross-compiling issue 😂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
I think using constants in test code is better for maintenance.