Skip to content

Commit be80d5f

Browse files
committed
Test using allocWithZone: as well
1 parent c454425 commit be80d5f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

objc2/src/macros.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,28 @@ mod tests {
368368
use super::*;
369369
use crate::rc::{Allocated, Id, Owned, Shared};
370370
use crate::runtime::Object;
371+
use crate::{Encoding, RefEncode};
372+
373+
#[repr(C)]
374+
struct _NSZone {
375+
_inner: [u8; 0],
376+
}
377+
378+
unsafe impl RefEncode for _NSZone {
379+
const ENCODING_REF: Encoding<'static> =
380+
Encoding::Pointer(&Encoding::Struct("_NSZone", &[]));
381+
}
382+
383+
#[test]
384+
fn test_macro_alloc() {
385+
let cls = class!(NSObject);
386+
387+
let _obj: Option<Id<Allocated<Object>, Shared>> = unsafe { msg_send_id![cls, alloc] };
388+
389+
let zone: *const _NSZone = ptr::null();
390+
let _obj: Option<Id<Allocated<Object>, Owned>> =
391+
unsafe { msg_send_id![cls, allocWithZone: zone] };
392+
}
371393

372394
#[test]
373395
fn test_macro() {

0 commit comments

Comments
 (0)