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

Use constants in bytes.rs test code #247

Merged
merged 3 commits into from
Feb 27, 2019
Merged

Use constants in bytes.rs test code #247

merged 3 commits into from
Feb 27, 2019

Conversation

luaneyed
Copy link
Contributor

I think using constants in test code is better for maintenance.

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 {
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@carllerche
Copy link
Member

Got a failing test!

@luaneyed
Copy link
Contributor Author

Oh, it's my first cross-compiling issue 😂
I fixed it!

Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@carllerche carllerche merged commit e13d2a7 into tokio-rs:v0.4.x Feb 27, 2019
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.

None yet

2 participants