Skip to content

exact_div: add tests #141939

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

Merged
merged 2 commits into from
Jun 4, 2025
Merged

exact_div: add tests #141939

merged 2 commits into from
Jun 4, 2025

Conversation

Qelxiros
Copy link
Contributor

@Qelxiros Qelxiros commented Jun 3, 2025

tracking issue: #139911

I neglected to add tests in my last PR (#141237), so I've added them here.

r? @workingjubilee (Feel free to reroll, I just picked you since you reviewed the last one.)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 3, 2025
@rust-log-analyzer

This comment has been minimized.

@Qelxiros Qelxiros force-pushed the 139911-exact-div-tests branch from 00e7551 to 2c4e592 Compare June 3, 2025 01:03
@rust-log-analyzer

This comment has been minimized.

@Qelxiros Qelxiros force-pushed the 139911-exact-div-tests branch from 2c4e592 to b72cf24 Compare June 3, 2025 02:34
@rust-log-analyzer

This comment has been minimized.

@Qelxiros Qelxiros force-pushed the 139911-exact-div-tests branch from b72cf24 to e87f138 Compare June 3, 2025 02:57
Copy link
Member

@workingjubilee workingjubilee left a comment

Choose a reason for hiding this comment

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

ah, np. I should've nagged you for them.


// failures
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(1, 2), None);
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(0, 0), None);
Copy link
Member

Choose a reason for hiding this comment

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

I suppose we could test (<$T>::MAX >> 1) + 1 divided by -1 as _ for unsigned integers, but it would just also be None, for the same reason 1, 2 is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what, if anything, you want me to change here.

Copy link
Member

Choose a reason for hiding this comment

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

Nada, just thought process effluvia.

@workingjubilee
Copy link
Member

feels weird to test signed integers without testing negative cases

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 4, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Qelxiros
Copy link
Contributor Author

Qelxiros commented Jun 4, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 4, 2025
@workingjubilee
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 4, 2025

📌 Commit 21a739f has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 4, 2025
Comment on lines +703 to +707
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), Some(EXACT_DIV_SUCCESS_QUOTIENT1));
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), EXACT_DIV_SUCCESS_QUOTIENT1);

// 18 / 3
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND2, EXACT_DIV_SUCCESS_DIVISOR2), Some(EXACT_DIV_SUCCESS_QUOTIENT2));
Copy link
Contributor

Choose a reason for hiding this comment

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

Not to necessarily block anything, but maybe want to hand wrap these so they don't wrap in the UI?

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 4, 2025
…=workingjubilee

exact_div: add tests

tracking issue: rust-lang#139911

I neglected to add tests in my last PR (rust-lang#141237), so I've added them here.

r? `@workingjubilee` (Feel free to reroll, I just picked you since you reviewed the last one.)
bors added a commit that referenced this pull request Jun 4, 2025
Rollup of 9 pull requests

Successful merges:

 - #141271 (Streamline some attr parsing APIs)
 - #141570 (Fix incorrect eq_unspanned in TokenStream)
 - #141857 (coretests: move float tests from num to floats module and use a more flexible macro to generate them)
 - #141893 (remove `f16: From<u16>`)
 - #141924 (Lightly tweak docs for BTree{Map,Set}::extract_if)
 - #141939 (exact_div: add tests)
 - #141959 (Add more missing 2015 edition directives)
 - #142002 (redesign stage 0 std follow-ups part2)
 - #142007 (Improve some `Visitor` comments.)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jun 4, 2025
Rollup of 7 pull requests

Successful merges:

 - #141271 (Streamline some attr parsing APIs)
 - #141570 (Fix incorrect eq_unspanned in TokenStream)
 - #141893 (remove `f16: From<u16>`)
 - #141924 (Lightly tweak docs for BTree{Map,Set}::extract_if)
 - #141939 (exact_div: add tests)
 - #141959 (Add more missing 2015 edition directives)
 - #142007 (Improve some `Visitor` comments.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5be375d into rust-lang:master Jun 4, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 4, 2025
rust-timer added a commit that referenced this pull request Jun 4, 2025
Rollup merge of #141939 - Qelxiros:139911-exact-div-tests, r=workingjubilee

exact_div: add tests

tracking issue: #139911

I neglected to add tests in my last PR (#141237), so I've added them here.

r? ``@workingjubilee`` (Feel free to reroll, I just picked you since you reviewed the last one.)
@Qelxiros Qelxiros deleted the 139911-exact-div-tests branch June 4, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants