summaryrefslogtreecommitdiff
path: root/src/poisonable.rs
diff options
context:
space:
mode:
authorMica White <botahamec@gmail.com>2024-12-01 15:28:44 -0500
committerMica White <botahamec@gmail.com>2024-12-01 15:29:19 -0500
commit48aaedad542b9c6cbdc85d22517cd0d151f38443 (patch)
treeb5b197c47476e88b9926852c73a84f24b6497c77 /src/poisonable.rs
parent0140f58043a2a00312d31907253cc718985e1e6c (diff)
Unit testing
Diffstat (limited to 'src/poisonable.rs')
-rw-r--r--src/poisonable.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/poisonable.rs b/src/poisonable.rs
index 6cc234e..d664291 100644
--- a/src/poisonable.rs
+++ b/src/poisonable.rs
@@ -1,8 +1,6 @@
use std::marker::PhantomData;
use std::sync::atomic::AtomicBool;
-use crate::lockable::{Lockable, RawLock};
-
mod error;
mod flag;
mod guard;
@@ -92,3 +90,19 @@ pub type PoisonResult<Guard> = Result<Guard, PoisonError<Guard>>;
/// lock might not have been acquired for other reasons.
pub type TryLockPoisonableResult<'flag, 'key, G, Key> =
Result<PoisonGuard<'flag, 'key, G, Key>, TryLockPoisonableError<'flag, 'key, G, Key>>;
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::{Mutex, ThreadKey};
+
+ #[test]
+ fn display_works() {
+ let key = ThreadKey::get().unwrap();
+ let mutex = Poisonable::new(Mutex::new("Hello, world!"));
+
+ let guard = mutex.lock(key).unwrap();
+
+ assert_eq!(guard.to_string(), "Hello, world!");
+ }
+}