Skip to content

Commit

Permalink
Add test for chain() adaptor producing too many items.
Browse files Browse the repository at this point in the history
  • Loading branch information
gendx committed Nov 11, 2024
1 parent 6e9b773 commit 8faa4d1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ mod test {
#[cfg(feature = "nightly")]
test_source_range_inclusive_u128_too_large => fail("cannot iterate over a range with more than usize::MAX (18446744073709551615) items"),
test_source_adaptor_chain,
test_source_adaptor_chain_overflow => fail("called chain() with sources that together produce more than usize::MAX (18446744073709551615) items"),
test_source_adaptor_enumerate,
test_source_adaptor_rev,
test_source_adaptor_skip,
Expand Down Expand Up @@ -1008,6 +1009,21 @@ mod test {
assert_eq!(sum, INPUT_LEN * (INPUT_LEN + 1) / 2);
}

fn test_source_adaptor_chain_overflow(range_strategy: RangeStrategy) {
let mut thread_pool = ThreadPoolBuilder {
num_threads: ThreadCount::AvailableParallelism,
range_strategy,
cpu_pinning: CpuPinningPolicy::No,
}
.build();

let _ = (0..usize::MAX)
.into_par_iter()
.chain((0..1).into_par_iter())
.with_thread_pool(&mut thread_pool)
.reduce(|| 0, |x, y| x + y);
}

fn test_source_adaptor_enumerate(range_strategy: RangeStrategy) {
let mut thread_pool = ThreadPoolBuilder {
num_threads: ThreadCount::AvailableParallelism,
Expand Down

0 comments on commit 8faa4d1

Please sign in to comment.