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/collection/guard.rs | |
| parent | 0140f58043a2a00312d31907253cc718985e1e6c (diff) | |
Unit testing
Diffstat (limited to 'src/collection/guard.rs')
| -rw-r--r-- | src/collection/guard.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/collection/guard.rs b/src/collection/guard.rs index 8857c5f..0b8a583 100644 --- a/src/collection/guard.rs +++ b/src/collection/guard.rs @@ -42,3 +42,19 @@ impl<'key, Guard, Key: Keyable> AsMut<Guard> for LockGuard<'key, Guard, Key> { &mut self.guard } } + +#[cfg(test)] +mod tests { + use crate::collection::OwnedLockCollection; + use crate::{RwLock, ThreadKey}; + + use super::*; + + #[test] + fn guard_display_works() { + let key = ThreadKey::get().unwrap(); + let lock = OwnedLockCollection::new(RwLock::new("Hello, world!")); + let guard = lock.read(key); + assert_eq!(guard.to_string(), "Hello, world!".to_string()); + } +} |
