Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Added more tests to cast (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao authored Aug 5, 2021
1 parent 9ca5815 commit e92f47a
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1,548 deletions.
28 changes: 13 additions & 15 deletions src/compute/aggregate/min_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,81 +372,79 @@ mod tests {
}

// todo: convert me
/*
#[test]
fn test_string_min_max_with_nulls() {
let a = StringArray::from(vec![Some("b"), None, None, Some("a"), Some("c")]);
let a = Utf8Array::<i32>::from(&[Some("b"), None, None, Some("a"), Some("c")]);
assert_eq!("a", min_string(&a).unwrap());
assert_eq!("c", max_string(&a).unwrap());
}

#[test]
fn test_string_min_max_all_nulls() {
let a = StringArray::from(vec![None, None]);
let a = Utf8Array::<i32>::from(&[None::<&str>, None]);
assert_eq!(None, min_string(&a));
assert_eq!(None, max_string(&a));
}

#[test]
fn test_string_min_max_1() {
let a = StringArray::from(vec![None, None, Some("b"), Some("a")]);
let a = Utf8Array::<i32>::from(&[None, None, Some("b"), Some("a")]);
assert_eq!(Some("a"), min_string(&a));
assert_eq!(Some("b"), max_string(&a));
}

#[test]
fn test_boolean_min_max_empty() {
let a = BooleanArray::from(vec![] as Vec<Option<bool>>);
let a = BooleanArray::new_empty();
assert_eq!(None, min_boolean(&a));
assert_eq!(None, max_boolean(&a));
}

#[test]
fn test_boolean_min_max_all_null() {
let a = BooleanArray::from(vec![None, None]);
let a = BooleanArray::from(&[None, None]);
assert_eq!(None, min_boolean(&a));
assert_eq!(None, max_boolean(&a));
}

#[test]
fn test_boolean_min_max_no_null() {
let a = BooleanArray::from(vec![Some(true), Some(false), Some(true)]);
let a = BooleanArray::from(&[Some(true), Some(false), Some(true)]);
assert_eq!(Some(false), min_boolean(&a));
assert_eq!(Some(true), max_boolean(&a));
}

#[test]
fn test_boolean_min_max() {
let a = BooleanArray::from(vec![Some(true), Some(true), None, Some(false), None]);
let a = BooleanArray::from(&[Some(true), Some(true), None, Some(false), None]);
assert_eq!(Some(false), min_boolean(&a));
assert_eq!(Some(true), max_boolean(&a));

let a = BooleanArray::from(vec![None, Some(true), None, Some(false), None]);
let a = BooleanArray::from(&[None, Some(true), None, Some(false), None]);
assert_eq!(Some(false), min_boolean(&a));
assert_eq!(Some(true), max_boolean(&a));

let a = BooleanArray::from(vec![Some(false), Some(true), None, Some(false), None]);
let a = BooleanArray::from(&[Some(false), Some(true), None, Some(false), None]);
assert_eq!(Some(false), min_boolean(&a));
assert_eq!(Some(true), max_boolean(&a));
}

#[test]
fn test_boolean_min_max_smaller() {
let a = BooleanArray::from(vec![Some(false)]);
let a = BooleanArray::from(&[Some(false)]);
assert_eq!(Some(false), min_boolean(&a));
assert_eq!(Some(false), max_boolean(&a));

let a = BooleanArray::from(vec![None, Some(false)]);
let a = BooleanArray::from(&[None, Some(false)]);
assert_eq!(Some(false), min_boolean(&a));
assert_eq!(Some(false), max_boolean(&a));

let a = BooleanArray::from(vec![None, Some(true)]);
let a = BooleanArray::from(&[None, Some(true)]);
assert_eq!(Some(true), min_boolean(&a));
assert_eq!(Some(true), max_boolean(&a));

let a = BooleanArray::from(vec![Some(true)]);
let a = BooleanArray::from(&[Some(true)]);
assert_eq!(Some(true), min_boolean(&a));
assert_eq!(Some(true), max_boolean(&a));
}
*/
}
Loading

0 comments on commit e92f47a

Please sign in to comment.