summaryrefslogtreecommitdiff
path: root/src/mutex.rs
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2025-01-12 15:04:01 -0500
committerBotahamec <botahamec@outlook.com>2025-01-12 15:04:01 -0500
commit280a61ad7b74019c7aad8b7306a0dd7cfb11359c (patch)
tree40d97d4e183c1bc551194944876b099d875f361d /src/mutex.rs
parentbf95904b3532a9175a7bfa14a3f216abbd15ee98 (diff)
More unit tests
Diffstat (limited to 'src/mutex.rs')
-rw-r--r--src/mutex.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mutex.rs b/src/mutex.rs
index 004e5d4..99d0981 100644
--- a/src/mutex.rs
+++ b/src/mutex.rs
@@ -161,7 +161,7 @@ pub struct MutexGuard<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable + 'key, R: RawM
#[cfg(test)]
mod tests {
- use crate::ThreadKey;
+ use crate::{LockCollection, ThreadKey};
use super::*;
@@ -199,6 +199,21 @@ mod tests {
}
#[test]
+ fn ord_works() {
+ let key = ThreadKey::get().unwrap();
+ let mutex1: crate::Mutex<_> = Mutex::new(1);
+ let mutex2: crate::Mutex<_> = Mutex::new(2);
+ let mutex3: crate::Mutex<_> = Mutex::new(2);
+ let collection = LockCollection::try_new((&mutex1, &mutex2, &mutex3)).unwrap();
+
+ let guard = collection.lock(key);
+ assert!(guard.0 < guard.1);
+ assert!(guard.1 > guard.0);
+ assert!(guard.1 == guard.2);
+ assert!(guard.0 != guard.2)
+ }
+
+ #[test]
fn dropping_guard_releases_mutex() {
let mut key = ThreadKey::get().unwrap();
let mutex: crate::Mutex<_> = Mutex::new("Hello, world!");