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
Changes from 1 commit
68ce0bc
01619b3
5cdb7c0
9004bba
c2dd788
d788f99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,6 +445,16 @@ mod tests { | |
use super::*; | ||
use crate::datatypes::*; | ||
|
||
/// A helper macro to generate test cases. | ||
/// # Arguments | ||
/// * `input` - A vector which array can be built from. | ||
/// * `start` - The start index of the substring. | ||
/// * `len` - The length of the substring. | ||
/// * `result` - The expected result of substring, which is a vector that array can be built from. | ||
/// # Return | ||
/// A vector of `(input, start, len, result)`. | ||
/// | ||
/// Users can provide any number of `(start, len, result)` to generate test cases for one `input`. | ||
macro_rules! gen_test_cases { | ||
($input:expr, $(($start:expr, $len:expr, $result:expr)), *) => { | ||
[ | ||
|
@@ -455,6 +465,12 @@ mod tests { | |
}; | ||
} | ||
|
||
/// A helper macro to test the substring functions. | ||
/// # Arguments | ||
/// * `cases` - The test cases which is a vector of `(input, start, len, result)`. | ||
/// Please look at [`gen_test_cases`] to find how to generate it. | ||
/// * `array_ty` - The array type. | ||
/// * `substring_fn` - Either [`substring`] or [`substring_by_char`]. | ||
macro_rules! do_test { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Updated! |
||
($cases:expr, $array_ty:ty, $substring_fn:ident) => { | ||
$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.
❤️