MCPcopy Create free account
hub / github.com/SSheldon/rust-objc / test_strong_clone

Function test_strong_clone

src/rc/mod.rs:59–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57
58 #[test]
59 fn test_strong_clone() {
60 fn retain_count(obj: *mut Object) -> usize {
61 unsafe { msg_send![obj, retainCount] }
62 }
63
64 let obj = unsafe {
65 StrongPtr::new(msg_send![class!(NSObject), new])
66 };
67 assert!(retain_count(*obj) == 1);
68
69 let cloned = obj.clone();
70 assert!(retain_count(*cloned) == 2);
71 assert!(retain_count(*obj) == 2);
72
73 drop(obj);
74 assert!(retain_count(*cloned) == 1);
75 }
76
77 #[test]
78 fn test_weak() {

Callers

nothing calls this directly

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected