You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/16 19:46:26 UTC

[GitHub] [arrow-rs] alamb commented on a diff in pull request #1853: Clean up the test code of `substring` kernel.

alamb commented on code in PR #1853:
URL: https://github.com/apache/arrow-rs/pull/1853#discussion_r899462784


##########
arrow/src/compute/kernels/substring.rs:
##########
@@ -445,64 +445,61 @@ mod tests {
     use super::*;
     use crate::datatypes::*;
 
-    #[allow(clippy::type_complexity)]
+    macro_rules! gen_test_cases {
+        ($input:expr, $(($start:expr, $len:expr, $result:expr)), *) => {
+            [
+                $(
+                    ($input.clone(), $start, $len, $result),
+                )*
+            ]
+        };
+    }
+
+    macro_rules! do_test {

Review Comment:
   I think some docstrings explaining what was going on here (specifically what the expectations on `$cases) are would have helped me understand this code



##########
arrow/src/compute/kernels/substring.rs:
##########
@@ -445,64 +445,61 @@ mod tests {
     use super::*;
     use crate::datatypes::*;
 
-    #[allow(clippy::type_complexity)]
+    macro_rules! gen_test_cases {
+        ($input:expr, $(($start:expr, $len:expr, $result:expr)), *) => {
+            [
+                $(
+                    ($input.clone(), $start, $len, $result),
+                )*
+            ]
+        };
+    }
+
+    macro_rules! do_test {
+        ($cases:expr, $array_ty:ty, $substring_fn:ident) => {
+            $cases.into_iter().try_for_each::<_, Result<()>>(

Review Comment:
   I wonder why bother with `try_for_each` and not just use `unwrap()` or `expect()`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org