Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: fix Semaphore::MAX_PERMITS test #5582

Merged
merged 2 commits into from Mar 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions tokio/src/sync/tests/semaphore_batch.rs
@@ -1,6 +1,8 @@
use crate::sync::batch_semaphore::Semaphore;
use tokio_test::*;

const MAX_PERMITS: usize = crate::sync::Semaphore::MAX_PERMITS;

#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;

Expand Down Expand Up @@ -168,12 +170,16 @@ fn poll_acquire_one_zero_permits() {
assert_ready_ok!(acquire.poll());
}

#[test]
fn max_permits_doesnt_panic() {
Semaphore::new(MAX_PERMITS);
}

#[test]
#[should_panic]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
fn validates_max_permits() {
use std::usize;
Semaphore::new((usize::MAX >> 2) + 1);
Semaphore::new(MAX_PERMITS+1);
}

#[test]
Expand Down