add basic tests

This commit is contained in:
numzero 2026-05-07 20:53:58 +03:00
parent eb18c5ad24
commit fc57085534

View File

@ -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");
}
}