Skip to content

Commit 32a2f85

Browse files
author
Nicolas Trinquier
committed
Add tests for limit and filter
1 parent 0ca0412 commit 32a2f85

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

rust/arrow/src/compute/array_ops.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,26 @@ mod tests {
450450
assert_eq!(5, min(&a).unwrap());
451451
assert_eq!(9, max(&a).unwrap());
452452
}
453+
454+
#[test]
455+
fn test_filter_array() {
456+
let a = Int32Array::from(vec![5, 6, 7, 8, 9]);
457+
let b = BooleanArray::from(vec![true, false, false, true, false]);
458+
let c = filter(&a, &b).unwrap();
459+
let d = c.as_ref().as_any().downcast_ref::<Int32Array>().unwrap();
460+
assert_eq!(2, d.len());
461+
assert_eq!(5, d.value(0));
462+
assert_eq!(8, d.value(1));
463+
}
464+
465+
#[test]
466+
fn test_limit_array() {
467+
let a = Int32Array::from(vec![5, 6, 7, 8, 9]);
468+
let c = limit(&a, 3).unwrap();
469+
let d = c.as_ref().as_any().downcast_ref::<Int32Array>().unwrap();
470+
assert_eq!(3, d.len());
471+
assert_eq!(5, d.value(0));
472+
assert_eq!(6, d.value(1));
473+
assert_eq!(7, d.value(2));
474+
}
453475
}

0 commit comments

Comments
 (0)