aboutsummaryrefslogtreecommitdiff
path: root/src/castable_factory/threadsafe.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/castable_factory/threadsafe.rs')
-rw-r--r--src/castable_factory/threadsafe.rs38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/castable_factory/threadsafe.rs b/src/castable_factory/threadsafe.rs
index 84e15b9..8f9c072 100644
--- a/src/castable_factory/threadsafe.rs
+++ b/src/castable_factory/threadsafe.rs
@@ -91,21 +91,45 @@ mod tests
{
use super::*;
+ #[derive(Debug, PartialEq, Eq)]
+ struct Bacon
+ {
+ heal_amount: u32,
+ }
+
#[test]
fn can_call()
{
- #[derive(Debug, PartialEq, Eq)]
- struct Bacon
- {
- heal_amount: u32,
- }
+ let castable_factory = ThreadsafeCastableFactory::new(&|heal_amount| {
+ TransientPtr::new(Bacon { heal_amount })
+ });
+
+ let output = castable_factory.call((27,));
+ assert_eq!(output, TransientPtr::new(Bacon { heal_amount: 27 }));
+ }
+
+ #[test]
+ fn can_call_mut()
+ {
+ let mut castable_factory = ThreadsafeCastableFactory::new(&|heal_amount| {
+ TransientPtr::new(Bacon { heal_amount })
+ });
+
+ let output = castable_factory.call_mut((1092,));
+
+ assert_eq!(output, TransientPtr::new(Bacon { heal_amount: 1092 }));
+ }
+
+ #[test]
+ fn can_call_once()
+ {
let castable_factory = ThreadsafeCastableFactory::new(&|heal_amount| {
TransientPtr::new(Bacon { heal_amount })
});
- let output = castable_factory(27);
+ let output = castable_factory.call_once((547,));
- assert_eq!(output, Box::new(Bacon { heal_amount: 27 }));
+ assert_eq!(output, TransientPtr::new(Bacon { heal_amount: 547 }));
}
}