diff options
| author | Mica White <botahamec@gmail.com> | 2024-12-01 15:28:44 -0500 |
|---|---|---|
| committer | Mica White <botahamec@gmail.com> | 2024-12-01 15:29:19 -0500 |
| commit | 48aaedad542b9c6cbdc85d22517cd0d151f38443 (patch) | |
| tree | b5b197c47476e88b9926852c73a84f24b6497c77 /src/poisonable.rs | |
| parent | 0140f58043a2a00312d31907253cc718985e1e6c (diff) | |
Unit testing
Diffstat (limited to 'src/poisonable.rs')
| -rw-r--r-- | src/poisonable.rs | 18 |
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!"); + } +} |
