Skip to content

Commit

Permalink
Add unit tests for ThreadPool::num_threads().
Browse files Browse the repository at this point in the history
  • Loading branch information
gendx committed Dec 7, 2024
1 parent b5ab42a commit 566ef43
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/core/thread_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,4 +659,29 @@ mod test {
}
.build();
}

#[test]
fn test_num_threads() {
let thread_pool = ThreadPoolBuilder {
num_threads: ThreadCount::AvailableParallelism,
range_strategy: RangeStrategy::Fixed,
cpu_pinning: CpuPinningPolicy::No,
}
.build();
assert_eq!(
thread_pool.num_threads(),
std::thread::available_parallelism().unwrap()
);

let thread_pool = ThreadPoolBuilder {
num_threads: ThreadCount::try_from(4).unwrap(),
range_strategy: RangeStrategy::Fixed,
cpu_pinning: CpuPinningPolicy::No,
}
.build();
assert_eq!(
thread_pool.num_threads(),
NonZeroUsize::try_from(4).unwrap()
);
}
}

0 comments on commit 566ef43

Please sign in to comment.