summaryrefslogtreecommitdiffstats
path: root/tokio/tests/sync_semaphore.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio/tests/sync_semaphore.rs')
-rw-r--r--tokio/tests/sync_semaphore.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tokio/tests/sync_semaphore.rs b/tokio/tests/sync_semaphore.rs
index 1cb0c749..a33b878b 100644
--- a/tokio/tests/sync_semaphore.rs
+++ b/tokio/tests/sync_semaphore.rs
@@ -79,3 +79,17 @@ async fn stresstest() {
let _p5 = sem.try_acquire().unwrap();
assert!(sem.try_acquire().is_err());
}
+
+#[test]
+fn add_max_amount_permits() {
+ let s = tokio::sync::Semaphore::new(0);
+ s.add_permits(usize::MAX >> 3);
+ assert_eq!(s.available_permits(), usize::MAX >> 3);
+}
+
+#[test]
+#[should_panic]
+fn add_more_than_max_amount_permits() {
+ let s = tokio::sync::Semaphore::new(1);
+ s.add_permits(usize::MAX >> 3);
+}