-
Notifications
You must be signed in to change notification settings - Fork 838
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
Clean up the test code of substring
kernel.
#1853
Conversation
Blocked by #1852 |
Codecov Report
@@ Coverage Diff @@
## master #1853 +/- ##
==========================================
- Coverage 83.51% 83.43% -0.08%
==========================================
Files 201 203 +2
Lines 56948 56954 +6
==========================================
- Hits 47559 47519 -40
- Misses 9389 9435 +46
Continue to review full report at Codecov.
|
Signed-off-by: remzi <13716567376yh@gmail.com>
Sorry for the delay, I'll try to get to this later today if nobody else does, I'm currently on holiday and reviewing large PRs like this on a phone is challenging 😅 |
Never mind. Have a good holiday! 🏝 |
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.
Thank you @HaoYang670 -- this looks like a nice cleanup to me
}; | ||
} | ||
|
||
macro_rules! do_test { |
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.
I think some docstrings explaining what was going on here (specifically what the expectations on `$cases) are would have helped me understand this code
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.
Updated!
|
||
macro_rules! do_test { | ||
($cases:expr, $array_ty:ty, $substring_fn:ident) => { | ||
$cases.into_iter().try_for_each::<_, Result<()>>( |
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.
I wonder why bother with try_for_each
and not just use unwrap()
or expect()
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.
Great catch! Updated.
Signed-off-by: remzi <13716567376yh@gmail.com>
Signed-off-by: remzi <13716567376yh@gmail.com>
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.
Looks great -- thanks again @HaoYang670
@@ -445,6 +445,16 @@ mod tests { | |||
use super::*; | |||
use crate::datatypes::*; | |||
|
|||
/// A helper macro to generate test cases. |
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.
❤️
Signed-off-by: remzi 13716567376yh@gmail.com
Which issue does this PR close?
Closes #1801.
Rationale for this change
Avoid repeated code.
More readable.
Less code is better.
What changes are included in this PR?
Use macros.
Better format.
Are there any user-facing changes?
No.