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

Unify assert_eq!(…)/assert_ne!(…) to take args in order of …!(actual, expected) #385

Merged
merged 2 commits into from
Jan 4, 2023

Conversation

regexident
Copy link
Member

While there isn't an explicit convention for this in Rust the stdlib docs all use assert_eq!(actual, expected)/assert_ne!(actual, expected) —as do the Rust by Example and The Rust Programming Language (*) books— making it a sort of implicit convention.

The project contains over 2000 occurrences of the pattern /assert_(ne|eq|ok|err)!/, so this PR is clearly a best-effort attempt to unify the arg order. There are no doubt instances that I missed either due to inattentiveness after having gone through thousands of lines of code, or ambiguous argument names.

@regexident regexident requested review from algesten and rainliu January 4, 2023 09:29
Copy link
Member

@algesten algesten left a comment

Choose a reason for hiding this comment

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

I personally don't care much about the argument order of asserts, but I'm happy to have cleaner code. Let's merge it! :)

@regexident regexident force-pushed the regexident/unify-assert-eq-args-order-in-tests branch from a18ae19 to 30505af Compare January 4, 2023 09:48
@regexident
Copy link
Member Author

Definitely not a must-have, but a consistent arg ordering makes debugging test failures easier in my experience by not having first figure out which is which.

…tual, expected)`

While there isn't an explicit convention for this in Rust the stdlib docs all use `assert_eq!(actual, expected)`, making it a sort of implicit convention.
@regexident regexident force-pushed the regexident/unify-assert-eq-args-order-in-tests branch from 30505af to 6686933 Compare January 4, 2023 10:04
@codecov
Copy link

codecov bot commented Jan 4, 2023

Codecov Report

Base: 59.86% // Head: 61.09% // Increases project coverage by +1.22% 🎉

Coverage data is based on head (6686933) compared to base (a1492d1).
Patch coverage: 67.30% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #385      +/-   ##
==========================================
+ Coverage   59.86%   61.09%   +1.22%     
==========================================
  Files         504      537      +33     
  Lines       48000    49624    +1624     
  Branches    12503    12594      +91     
==========================================
+ Hits        28736    30318    +1582     
+ Misses      10024     9978      -46     
- Partials     9240     9328      +88     
Impacted Files Coverage Δ
data/src/data_channel/data_channel_test.rs 59.49% <0.00%> (ø)
dtls/src/crypto/crypto_test.rs 68.18% <ø> (ø)
ice/src/agent/agent_test.rs 66.19% <0.00%> (ø)
.../src/external_ip_mapper/external_ip_mapper_test.rs 50.61% <0.00%> (ø)
ice/src/mdns/mdns_test.rs 69.52% <0.00%> (ø)
ice/src/network_type/network_type_test.rs 77.96% <0.00%> (ø)
ice/src/priority/priority_test.rs 57.69% <0.00%> (ø)
ice/src/state/state_test.rs 92.85% <ø> (ø)
ice/src/tcp_type/tcp_type_test.rs 27.27% <0.00%> (ø)
ice/src/url/url_test.rs 80.70% <0.00%> (ø)
... and 135 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@regexident regexident merged commit 99037ca into master Jan 4, 2023
@k0nserv k0nserv deleted the regexident/unify-assert-eq-args-order-in-tests branch January 4, 2023 11:37
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.

2 participants