MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_true_false_count

Function test_true_false_count

arrow-array/src/array/boolean_array.rs:1102–1126  ·  view source on GitHub ↗

Takes too long

()

Source from the content-addressed store, hash-verified

1100 #[test]
1101 #[cfg_attr(miri, ignore)] // Takes too long
1102 fn test_true_false_count() {
1103 let mut rng = rng();
1104
1105 for _ in 0..10 {
1106 // No nulls
1107 let d: Vec<_> = (0..2000).map(|_| rng.random_bool(0.5)).collect();
1108 let b = BooleanArray::from(d.clone());
1109
1110 let expected_true = d.iter().filter(|x| **x).count();
1111 assert_eq!(b.true_count(), expected_true);
1112 assert_eq!(b.false_count(), d.len() - expected_true);
1113
1114 // With nulls
1115 let d: Vec<_> = (0..2000)
1116 .map(|_| rng.random_bool(0.5).then(|| rng.random_bool(0.5)))
1117 .collect();
1118 let b = BooleanArray::from(d.clone());
1119
1120 let expected_true = d.iter().filter(|x| matches!(x, Some(true))).count();
1121 assert_eq!(b.true_count(), expected_true);
1122
1123 let expected_false = d.iter().filter(|x| matches!(x, Some(false))).count();
1124 assert_eq!(b.false_count(), expected_false);
1125 }
1126 }
1127
1128 #[test]
1129 fn test_into_parts() {

Callers

nothing calls this directly

Calls 5

collectMethod · 0.80
filterMethod · 0.80
cloneMethod · 0.45
countMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected