Skip to content

Commit

Permalink
Merge #78
Browse files Browse the repository at this point in the history
78: test: use collect() over from_iter() r=Kerollmops a=domodwyer

Change all calls to from_iter() into calls to collect().

It was only test code so no worries! Quick bit of regex (sometimes) saves the day 👍 

Closes #77.

Co-authored-by: Dom <[email protected]>
  • Loading branch information
bors[bot] and domodwyer authored Dec 5, 2020
2 parents 32107a4 + 51b4f9d commit b92076b
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 117 deletions.
2 changes: 1 addition & 1 deletion src/bitmap/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl RoaringBitmap {
/// use roaring::RoaringBitmap;
/// use std::iter::FromIterator;
///
/// let bitmap = RoaringBitmap::from_iter(1..3);
/// let bitmap = (1..3).collect::<RoaringBitmap>();
/// let mut iter = bitmap.iter();
///
/// assert_eq!(iter.next(), Some(1));
Expand Down
2 changes: 1 addition & 1 deletion src/treemap/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl RoaringTreemap {
/// let original = RoaringTreemap::from_iter(0..6000);
/// let mut bitmaps = original.bitmaps();
///
/// assert_eq!(bitmaps.next(), Some((0, &RoaringBitmap::from_iter(0..6000))));
/// assert_eq!(bitmaps.next(), Some((0, &(0..6000).collect::<RoaringBitmap>())));
/// assert_eq!(bitmaps.next(), None);
/// ```
pub fn bitmaps(&self) -> BitmapIter {
Expand Down
4 changes: 2 additions & 2 deletions tests/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use std::iter::FromIterator;

#[test]
fn array() {
let original = RoaringBitmap::from_iter(0..2000);
let original = (0..2000).collect::<RoaringBitmap>();
let clone = original.clone();

assert_eq!(clone, original);
}

#[test]
fn bitmap() {
let original = RoaringBitmap::from_iter(0..6000);
let original = (0..6000).collect::<RoaringBitmap>();
let clone = original.clone();

assert_eq!(clone, original);
Expand Down
40 changes: 20 additions & 20 deletions tests/difference_with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::iter::FromIterator;

#[test]
fn array() {
let mut bitmap1 = RoaringBitmap::from_iter(0..2000);
let bitmap2 = RoaringBitmap::from_iter(1000..3000);
let bitmap3 = RoaringBitmap::from_iter(0..1000);
let mut bitmap1 = (0..2000).collect::<RoaringBitmap>();
let bitmap2 = (1000..3000).collect::<RoaringBitmap>();
let bitmap3 = (0..1000).collect::<RoaringBitmap>();

bitmap1.difference_with(&bitmap2);

Expand All @@ -16,8 +16,8 @@ fn array() {

#[test]
fn no_difference() {
let mut bitmap1 = RoaringBitmap::from_iter(1..3);
let bitmap2 = RoaringBitmap::from_iter(1..3);
let mut bitmap1 = (1..3).collect::<RoaringBitmap>();
let bitmap2 = (1..3).collect::<RoaringBitmap>();

bitmap1.difference_with(&bitmap2);

Expand All @@ -26,9 +26,9 @@ fn no_difference() {

#[test]
fn array_and_bitmap() {
let mut bitmap1 = RoaringBitmap::from_iter(0..2000);
let bitmap2 = RoaringBitmap::from_iter(1000..8000);
let bitmap3 = RoaringBitmap::from_iter(0..1000);
let mut bitmap1 = (0..2000).collect::<RoaringBitmap>();
let bitmap2 = (1000..8000).collect::<RoaringBitmap>();
let bitmap3 = (0..1000).collect::<RoaringBitmap>();

bitmap1.difference_with(&bitmap2);

Expand All @@ -37,9 +37,9 @@ fn array_and_bitmap() {

#[test]
fn bitmap_to_bitmap() {
let mut bitmap1 = RoaringBitmap::from_iter(0..12000);
let bitmap2 = RoaringBitmap::from_iter(6000..18000);
let bitmap3 = RoaringBitmap::from_iter(0..6000);
let mut bitmap1 = (0..12000).collect::<RoaringBitmap>();
let bitmap2 = (6000..18000).collect::<RoaringBitmap>();
let bitmap3 = (0..6000).collect::<RoaringBitmap>();

bitmap1.difference_with(&bitmap2);

Expand All @@ -48,9 +48,9 @@ fn bitmap_to_bitmap() {

#[test]
fn bitmap_to_array() {
let mut bitmap1 = RoaringBitmap::from_iter(0..6000);
let bitmap2 = RoaringBitmap::from_iter(3000..9000);
let bitmap3 = RoaringBitmap::from_iter(0..3000);
let mut bitmap1 = (0..6000).collect::<RoaringBitmap>();
let bitmap2 = (3000..9000).collect::<RoaringBitmap>();
let bitmap3 = (0..3000).collect::<RoaringBitmap>();

bitmap1.difference_with(&bitmap2);

Expand All @@ -59,9 +59,9 @@ fn bitmap_to_array() {

#[test]
fn bitmap_and_array_to_bitmap() {
let mut bitmap1 = RoaringBitmap::from_iter(0..12000);
let bitmap2 = RoaringBitmap::from_iter(9000..12000);
let bitmap3 = RoaringBitmap::from_iter(0..9000);
let mut bitmap1 = (0..12000).collect::<RoaringBitmap>();
let bitmap2 = (9000..12000).collect::<RoaringBitmap>();
let bitmap3 = (0..9000).collect::<RoaringBitmap>();

bitmap1.difference_with(&bitmap2);

Expand All @@ -70,9 +70,9 @@ fn bitmap_and_array_to_bitmap() {

#[test]
fn bitmap_and_array_to_array() {
let mut bitmap1 = RoaringBitmap::from_iter(0..6000);
let bitmap2 = RoaringBitmap::from_iter(3000..6000);
let bitmap3 = RoaringBitmap::from_iter(0..3000);
let mut bitmap1 = (0..6000).collect::<RoaringBitmap>();
let bitmap2 = (3000..6000).collect::<RoaringBitmap>();
let bitmap3 = (0..3000).collect::<RoaringBitmap>();

bitmap1.difference_with(&bitmap2);

Expand Down
34 changes: 17 additions & 17 deletions tests/intersect_with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::iter::FromIterator;

#[test]
fn array() {
let mut bitmap1 = RoaringBitmap::from_iter(0..2000);
let bitmap2 = RoaringBitmap::from_iter(1000..3000);
let bitmap3 = RoaringBitmap::from_iter(1000..2000);
let mut bitmap1 = (0..2000).collect::<RoaringBitmap>();
let bitmap2 = (1000..3000).collect::<RoaringBitmap>();
let bitmap3 = (1000..2000).collect::<RoaringBitmap>();

bitmap1.intersect_with(&bitmap2);

Expand All @@ -16,8 +16,8 @@ fn array() {

#[test]
fn no_intersection() {
let mut bitmap1 = RoaringBitmap::from_iter(0..2);
let bitmap2 = RoaringBitmap::from_iter(3..4);
let mut bitmap1 = (0..2).collect::<RoaringBitmap>();
let bitmap2 = (3..4).collect::<RoaringBitmap>();

bitmap1.intersect_with(&bitmap2);

Expand All @@ -26,9 +26,9 @@ fn no_intersection() {

#[test]
fn array_and_bitmap() {
let mut bitmap1 = RoaringBitmap::from_iter(0..2000);
let bitmap2 = RoaringBitmap::from_iter(1000..8000);
let bitmap3 = RoaringBitmap::from_iter(1000..2000);
let mut bitmap1 = (0..2000).collect::<RoaringBitmap>();
let bitmap2 = (1000..8000).collect::<RoaringBitmap>();
let bitmap3 = (1000..2000).collect::<RoaringBitmap>();

bitmap1.intersect_with(&bitmap2);

Expand All @@ -37,9 +37,9 @@ fn array_and_bitmap() {

#[test]
fn bitmap_to_bitmap() {
let mut bitmap1 = RoaringBitmap::from_iter(0..12000);
let bitmap2 = RoaringBitmap::from_iter(6000..18000);
let bitmap3 = RoaringBitmap::from_iter(6000..12000);
let mut bitmap1 = (0..12000).collect::<RoaringBitmap>();
let bitmap2 = (6000..18000).collect::<RoaringBitmap>();
let bitmap3 = (6000..12000).collect::<RoaringBitmap>();

bitmap1.intersect_with(&bitmap2);

Expand All @@ -48,9 +48,9 @@ fn bitmap_to_bitmap() {

#[test]
fn bitmap_to_array() {
let mut bitmap1 = RoaringBitmap::from_iter(0..6000);
let bitmap2 = RoaringBitmap::from_iter(3000..9000);
let bitmap3 = RoaringBitmap::from_iter(3000..6000);
let mut bitmap1 = (0..6000).collect::<RoaringBitmap>();
let bitmap2 = (3000..9000).collect::<RoaringBitmap>();
let bitmap3 = (3000..6000).collect::<RoaringBitmap>();

bitmap1.intersect_with(&bitmap2);

Expand All @@ -59,9 +59,9 @@ fn bitmap_to_array() {

#[test]
fn bitmap_and_array() {
let mut bitmap1 = RoaringBitmap::from_iter(0..12000);
let bitmap2 = RoaringBitmap::from_iter(7000..9000);
let bitmap3 = RoaringBitmap::from_iter(7000..9000);
let mut bitmap1 = (0..12000).collect::<RoaringBitmap>();
let bitmap2 = (7000..9000).collect::<RoaringBitmap>();
let bitmap3 = (7000..9000).collect::<RoaringBitmap>();

bitmap1.intersect_with(&bitmap2);

Expand Down
16 changes: 8 additions & 8 deletions tests/is_disjoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ use std::iter::FromIterator;

#[test]
fn array() {
let bitmap1 = RoaringBitmap::from_iter(0..2000);
let bitmap2 = RoaringBitmap::from_iter(4000..6000);
let bitmap1 = (0..2000).collect::<RoaringBitmap>();
let bitmap2 = (4000..6000).collect::<RoaringBitmap>();
assert_eq!(bitmap1.is_disjoint(&bitmap2), true);
}

#[test]
fn array_not() {
let bitmap1 = RoaringBitmap::from_iter(0..4000);
let bitmap2 = RoaringBitmap::from_iter(2000..6000);
let bitmap1 = (0..4000).collect::<RoaringBitmap>();
let bitmap2 = (2000..6000).collect::<RoaringBitmap>();
assert_eq!(bitmap1.is_disjoint(&bitmap2), false);
}

#[test]
fn bitmap() {
let bitmap1 = RoaringBitmap::from_iter(0..6000);
let bitmap2 = RoaringBitmap::from_iter(10000..16000);
let bitmap1 = (0..6000).collect::<RoaringBitmap>();
let bitmap2 = (10000..16000).collect::<RoaringBitmap>();
assert_eq!(bitmap1.is_disjoint(&bitmap2), true);
}

#[test]
fn bitmap_not() {
let bitmap1 = RoaringBitmap::from_iter(0..10000);
let bitmap2 = RoaringBitmap::from_iter(5000..15000);
let bitmap1 = (0..10000).collect::<RoaringBitmap>();
let bitmap2 = (5000..15000).collect::<RoaringBitmap>();
assert_eq!(bitmap1.is_disjoint(&bitmap2), false);
}

Expand Down
28 changes: 14 additions & 14 deletions tests/is_subset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,50 @@ use std::iter::FromIterator;

#[test]
fn array_not() {
let sup = RoaringBitmap::from_iter(0..2000);
let sub = RoaringBitmap::from_iter(1000..3000);
let sup = (0..2000).collect::<RoaringBitmap>();
let sub = (1000..3000).collect::<RoaringBitmap>();
assert_eq!(sub.is_subset(&sup), false);
}

#[test]
fn array() {
let sup = RoaringBitmap::from_iter(0..4000);
let sub = RoaringBitmap::from_iter(2000..3000);
let sup = (0..4000).collect::<RoaringBitmap>();
let sub = (2000..3000).collect::<RoaringBitmap>();
assert_eq!(sub.is_subset(&sup), true);
}

#[test]
fn array_bitmap_not() {
let sup = RoaringBitmap::from_iter(0..2000);
let sub = RoaringBitmap::from_iter(1000..15000);
let sup = (0..2000).collect::<RoaringBitmap>();
let sub = (1000..15000).collect::<RoaringBitmap>();
assert_eq!(sub.is_subset(&sup), false);
}

#[test]
fn bitmap_not() {
let sup = RoaringBitmap::from_iter(0..6000);
let sub = RoaringBitmap::from_iter(4000..10000);
let sup = (0..6000).collect::<RoaringBitmap>();
let sub = (4000..10000).collect::<RoaringBitmap>();
assert_eq!(sub.is_subset(&sup), false);
}

#[test]
fn bitmap() {
let sup = RoaringBitmap::from_iter(0..20000);
let sub = RoaringBitmap::from_iter(5000..15000);
let sup = (0..20000).collect::<RoaringBitmap>();
let sub = (5000..15000).collect::<RoaringBitmap>();
assert_eq!(sub.is_subset(&sup), true);
}

#[test]
fn bitmap_array_not() {
let sup = RoaringBitmap::from_iter(0..20000);
let sub = RoaringBitmap::from_iter(19000..21000);
let sup = (0..20000).collect::<RoaringBitmap>();
let sub = (19000..21000).collect::<RoaringBitmap>();
assert_eq!(sub.is_subset(&sup), false);
}

#[test]
fn bitmap_array() {
let sup = RoaringBitmap::from_iter(0..20000);
let sub = RoaringBitmap::from_iter(18000..20000);
let sup = (0..20000).collect::<RoaringBitmap>();
let sub = (18000..20000).collect::<RoaringBitmap>();
assert_eq!(sub.is_subset(&sup), true);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::iter::FromIterator;

#[test]
fn array() {
let original = RoaringBitmap::from_iter(0..2000);
let original = (0..2000).collect::<RoaringBitmap>();
let clone = RoaringBitmap::from_iter(&original);
let clone2 = RoaringBitmap::from_iter(original.clone());

Expand All @@ -15,7 +15,7 @@ fn array() {

#[test]
fn bitmap() {
let original = RoaringBitmap::from_iter(0..6000);
let original = (0..6000).collect::<RoaringBitmap>();
let clone = RoaringBitmap::from_iter(&original);
let clone2 = RoaringBitmap::from_iter(original.clone());

Expand Down
8 changes: 4 additions & 4 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn remove_range() {
#[test]
#[allow(clippy::range_plus_one)] // remove_range needs an exclusive range
fn remove_range_array() {
let mut bitmap = RoaringBitmap::from_iter(0..1000);
let mut bitmap = (0..1000).collect::<RoaringBitmap>();
for i in 0..1000 {
assert_eq!(bitmap.remove_range(i..i), 0);
assert_eq!(bitmap.remove_range(i..i + 1), 1);
Expand All @@ -80,7 +80,7 @@ fn remove_range_array() {
}

// remove [0, 2), [2, 4), ..
let mut bitmap = RoaringBitmap::from_iter(0..1000);
let mut bitmap = (0..1000).collect::<RoaringBitmap>();
for i in 0..1000 / 2 {
assert_eq!(bitmap.remove_range(i * 2..(i + 1) * 2), 2);
}
Expand Down Expand Up @@ -117,7 +117,7 @@ fn remove_range_bitmap() {

#[test]
fn to_bitmap() {
let bitmap = RoaringBitmap::from_iter(0..5000);
let bitmap = (0..5000).collect::<RoaringBitmap>();
assert_eq!(bitmap.len(), 5000);
for i in 1..5000 {
assert_eq!(bitmap.contains(i), true);
Expand All @@ -127,7 +127,7 @@ fn to_bitmap() {

#[test]
fn to_array() {
let mut bitmap = RoaringBitmap::from_iter(0..5000);
let mut bitmap = (0..5000).collect::<RoaringBitmap>();
for i in 3000..5000 {
bitmap.remove(i);
}
Expand Down
Loading

0 comments on commit b92076b

Please sign in to comment.