Add unit tests for BitSet intersect/subtract

This commit is contained in:
Will Crichton 2021-08-25 23:15:21 -07:00
parent 800d6531a9
commit 1c1603e0b5

View File

@ -110,12 +110,23 @@ fn hybrid_bitset() {
assert!(hybrid.superset(&sparse01358) && sparse01358.superset(&hybrid)); assert!(hybrid.superset(&sparse01358) && sparse01358.superset(&hybrid));
assert!(!dense10.union(&sparse01358)); assert!(!dense10.union(&sparse01358));
assert!(!dense256.union(&dense10)); assert!(!dense256.union(&dense10));
let mut dense = dense10;
assert!(dense10.clone().intersect(&sparse01358));
assert!(!sparse01358.clone().intersect(&dense10));
assert!(dense10.clone().subtract(&sparse01358));
assert!(sparse01358.clone().subtract(&dense10));
let mut dense = dense10.clone();
assert!(dense.union(&dense256)); assert!(dense.union(&dense256));
assert!(dense.superset(&dense256) && dense256.superset(&dense)); assert!(dense.superset(&dense256) && dense256.superset(&dense));
assert!(hybrid.union(&dense256)); assert!(hybrid.union(&dense256));
assert!(hybrid.superset(&dense256) && dense256.superset(&hybrid)); assert!(hybrid.superset(&dense256) && dense256.superset(&hybrid));
assert!(!dense10.clone().intersect(&dense256));
assert!(dense256.clone().intersect(&dense10));
assert!(dense10.clone().subtract(&dense256));
assert!(dense256.clone().subtract(&dense10));
assert_eq!(dense256.iter().count(), 256); assert_eq!(dense256.iter().count(), 256);
let mut dense0 = dense256; let mut dense0 = dense256;
for i in 0..256 { for i in 0..256 {