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


##########
arrow-arith/src/aggregate.rs:
##########
@@ -1132,61 +1152,116 @@ mod tests {
         assert!(max(&a).unwrap().is_nan());
     }
 
-    #[test]
-    fn test_binary_min_max_with_nulls() {
-        let a = BinaryArray::from(vec![
-            Some("b".as_bytes()),
-            None,
-            None,
-            Some(b"a"),
-            Some(b"c"),
-        ]);
-        assert_eq!(Some("a".as_bytes()), min_binary(&a));
-        assert_eq!(Some("c".as_bytes()), max_binary(&a));
-    }
-
-    #[test]
-    fn test_binary_min_max_no_null() {
-        let a = BinaryArray::from(vec![Some("b".as_bytes()), Some(b"a"), 
Some(b"c")]);
-        assert_eq!(Some("a".as_bytes()), min_binary(&a));
-        assert_eq!(Some("c".as_bytes()), max_binary(&a));
-    }
-
-    #[test]
-    fn test_binary_min_max_all_nulls() {
-        let a = BinaryArray::from(vec![None, None]);
-        assert_eq!(None, min_binary(&a));
-        assert_eq!(None, max_binary(&a));
-    }
+    macro_rules! test_binary {
+        ($NAME:ident, $ARRAY:expr, $EXPECTED_MIN:expr, $EXPECTED_MAX: expr) => 
{
+            #[test]
+            fn $NAME() {
+                let binary = BinaryArray::from($ARRAY);
+                assert_eq!($EXPECTED_MIN, min_binary(&binary));
+                assert_eq!($EXPECTED_MAX, max_binary(&binary));
 
-    #[test]
-    fn test_binary_min_max_1() {
-        let a = BinaryArray::from(vec![None, None, Some("b".as_bytes()), 
Some(b"a")]);
-        assert_eq!(Some("a".as_bytes()), min_binary(&a));
-        assert_eq!(Some("b".as_bytes()), max_binary(&a));
-    }
+                let large_binary = LargeBinaryArray::from($ARRAY);
+                assert_eq!($EXPECTED_MIN, min_binary(&large_binary));
+                assert_eq!($EXPECTED_MAX, max_binary(&large_binary));
 
-    #[test]
-    fn test_string_min_max_with_nulls() {
-        let a = StringArray::from(vec![Some("b"), None, None, Some("a"), 
Some("c")]);
-        assert_eq!(Some("a"), min_string(&a));
-        assert_eq!(Some("c"), max_string(&a));
-    }
-
-    #[test]
-    fn test_string_min_max_all_nulls() {
-        let v: Vec<Option<&str>> = vec![None, None];
-        let a = StringArray::from(v);
-        assert_eq!(None, min_string(&a));
-        assert_eq!(None, max_string(&a));
+                let binary_view = BinaryViewArray::from($ARRAY);
+                assert_eq!($EXPECTED_MIN, min_binary_view(&binary_view));
+                assert_eq!($EXPECTED_MAX, max_binary_view(&binary_view));
+            }
+        };
     }
 
-    #[test]
-    fn test_string_min_max_1() {
-        let a = StringArray::from(vec![None, None, Some("b"), Some("a")]);
-        assert_eq!(Some("a"), min_string(&a));
-        assert_eq!(Some("b"), max_string(&a));
-    }
+    test_binary!(
+        test_binary_min_max_with_nulls,
+        vec![
+            Some("b01234567890123".as_bytes()), // long bytes

Review Comment:
   Can you please add coverage here so it compares more than one large string 
(and maybe update the comments to reflect why this is important)?
   
   Perhaps something like
   
   ```rust
               Some("b01234XXXXXXXX".as_bytes()), // longer than 12 bytes, 
handled differenty than StringView
               Some("b01234567890123".as_bytes()), 
   ```
   
   Likewise for the string cases too



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to