1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
extern crate roaring;
use roaring::RoaringBitmap;
#[test]
fn array() {
let mut bitmap1 = (0..2000).collect::<RoaringBitmap>();
let bitmap2 = (1000..3000).collect::<RoaringBitmap>();
let bitmap3 = (0..1000).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, bitmap3);
}
#[test]
fn no_difference() {
let mut bitmap1 = (1..3).collect::<RoaringBitmap>();
let bitmap2 = (1..3).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, RoaringBitmap::new());
}
#[test]
fn array_and_bitmap() {
let mut bitmap1 = (0..2000).collect::<RoaringBitmap>();
let bitmap2 = (1000..8000).collect::<RoaringBitmap>();
let bitmap3 = (0..1000).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, bitmap3);
}
#[test]
fn bitmap_to_bitmap() {
let mut bitmap1 = (0..12000).collect::<RoaringBitmap>();
let bitmap2 = (6000..18000).collect::<RoaringBitmap>();
let bitmap3 = (0..6000).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, bitmap3);
}
#[test]
fn bitmap_to_array() {
let mut bitmap1 = (0..6000).collect::<RoaringBitmap>();
let bitmap2 = (3000..9000).collect::<RoaringBitmap>();
let bitmap3 = (0..3000).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, bitmap3);
}
#[test]
fn bitmap_and_array_to_bitmap() {
let mut bitmap1 = (0..12000).collect::<RoaringBitmap>();
let bitmap2 = (9000..12000).collect::<RoaringBitmap>();
let bitmap3 = (0..9000).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, bitmap3);
}
#[test]
fn bitmap_and_array_to_array() {
let mut bitmap1 = (0..6000).collect::<RoaringBitmap>();
let bitmap2 = (3000..6000).collect::<RoaringBitmap>();
let bitmap3 = (0..3000).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, bitmap3);
}
#[test]
fn arrays() {
let mut bitmap1 = (0..2000)
.chain(1_000_000..1_002_000)
.chain(2_000_000..2_001_000)
.collect::<RoaringBitmap>();
let bitmap2 = (1000..3000)
.chain(1_001_000..1_003_000)
.chain(2_000_000..2_001_000)
.collect::<RoaringBitmap>();
let bitmap3 = (0..1000).chain(1_000_000..1_001_000).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, bitmap3);
}
#[test]
fn arrays_removing_one_whole_container() {
let mut bitmap1 = (0..2000)
.chain(1_000_000..1_002_000)
.chain(2_000_000..2_001_000)
.collect::<RoaringBitmap>();
let bitmap2 = (0..3000)
.chain(1_001_000..1_003_000)
.chain(2_000_000..2_001_000)
.collect::<RoaringBitmap>();
let bitmap3 = (1_000_000..1_001_000).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, bitmap3);
}
#[test]
fn bitmaps() {
let mut bitmap1 = (0..6000)
.chain(1_000_000..1_012_000)
.chain(2_000_000..2_010_000)
.collect::<RoaringBitmap>();
let bitmap2 = (3000..9000)
.chain(1_006_000..1_018_000)
.chain(2_000_000..2_010_000)
.collect::<RoaringBitmap>();
let bitmap3 = (0..3000).chain(1_000_000..1_006_000).collect::<RoaringBitmap>();
bitmap1 -= bitmap2;
assert_eq!(bitmap1, bitmap3);
}
|