mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
sync: fix Semaphore::MAX_PERMITS
test (#5582)
This commit is contained in:
parent
92d33b7181
commit
822af18cf5
@ -1,6 +1,8 @@
|
|||||||
use crate::sync::batch_semaphore::Semaphore;
|
use crate::sync::batch_semaphore::Semaphore;
|
||||||
use tokio_test::*;
|
use tokio_test::*;
|
||||||
|
|
||||||
|
const MAX_PERMITS: usize = crate::sync::Semaphore::MAX_PERMITS;
|
||||||
|
|
||||||
#[cfg(tokio_wasm_not_wasi)]
|
#[cfg(tokio_wasm_not_wasi)]
|
||||||
use wasm_bindgen_test::wasm_bindgen_test as test;
|
use wasm_bindgen_test::wasm_bindgen_test as test;
|
||||||
|
|
||||||
@ -168,12 +170,16 @@ fn poll_acquire_one_zero_permits() {
|
|||||||
assert_ready_ok!(acquire.poll());
|
assert_ready_ok!(acquire.poll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn max_permits_doesnt_panic() {
|
||||||
|
Semaphore::new(MAX_PERMITS);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
|
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
|
||||||
fn validates_max_permits() {
|
fn validates_max_permits() {
|
||||||
use std::usize;
|
Semaphore::new(MAX_PERMITS + 1);
|
||||||
Semaphore::new((usize::MAX >> 2) + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user