summaryrefslogtreecommitdiff
path: root/src/mutex.rs
diff options
context:
space:
mode:
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!");