diff --git a/src/ptr.rs b/src/ptr.rs index fdcad87..4633274 100644 --- a/src/ptr.rs +++ b/src/ptr.rs @@ -82,4 +82,30 @@ pub use _to_ptr_own_ref as to_own_ref; #[cfg(test)] mod tests { use super::*; + + #[test] + fn test_ref() { + let obj = "some string".to_string(); + to_own_ref!(obj); + assert_eq!(*obj, "some string"); + } + + #[test] + fn test_mut() { + let obj = b"some string".to_vec(); + to_own_ref!(mut obj); + obj[0] = b'm'; + obj[1] = b'o'; + obj[2] = b'r'; + obj[3] = b'e'; + assert_eq!(*obj, b"more string"); + } + + #[test] + fn test_take() { + let obj = "some string".to_string(); + to_own_ref!(obj); + let s: String = obj.take(); + assert_eq!(s, "some string"); + } }