Skip to content

Commit

Permalink
Add more skip test conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
macklin-10x committed Sep 6, 2024
1 parent 08ace43 commit 010e34c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,14 +1859,21 @@ mod shard_tests {
let all_items = all_items_res?;
assert!(set_compare(&true_items, &all_items));

// Check that the skip_lazy feature produces the expected results.
let mut unsorted_reader_skip = UnsortedShardReader::<T1>::open(tmp.path());
let to_skip = (disk_chunk_size * 3) + 1;
let skipped = unsorted_reader_skip.skip_lazy(to_skip)?;
assert_eq!(to_skip, skipped);
let all_items_res_skip: Result<Vec<_>, Error> = unsorted_reader_skip.collect();
let all_items_skip = all_items_res_skip?;
assert_eq!(&all_items[to_skip..], &all_items_skip);
let check_unsorted_skip = |to_skip: usize| -> Result<(), Error> {
let mut unsorted_reader_skip = UnsortedShardReader::<T1>::open(tmp.path());
let skipped = unsorted_reader_skip.skip_lazy(to_skip)?;
assert_eq!(to_skip, skipped);
let all_items_res_skip: Result<Vec<_>, Error> = unsorted_reader_skip.collect();
let all_items_skip = all_items_res_skip?;
assert_eq!(&all_items[to_skip..], &all_items_skip);
Ok(())
};

check_unsorted_skip(0)?;
check_unsorted_skip(1)?;
check_unsorted_skip(disk_chunk_size)?;
check_unsorted_skip(n_items)?;
check_unsorted_skip((disk_chunk_size * 3) + 1)?;
}
Ok(())
}
Expand Down

0 comments on commit 010e34c

Please sign in to comment.