]>
git.saurik.com Git - apple/xnu.git/blob - tests/osptr_dumb.cpp
1 #include <darwintest.h>
2 #include <darwintest_utils.h>
8 # define OSPTR_LOG T_LOG
10 # define OSPTR_LOG printf
12 # define OSPTR_LOG(x...) do { } while(0)
16 T_META_NAMESPACE("osptr"),
17 T_META_CHECK_LEAKS(false),
18 T_META_RUN_CONCURRENTLY(true)
33 taggedRetain(void *tag
) const
37 taggedRelease(void *tag
) const
44 void *OSMetaClassBase::type_id
;
46 #define OSTypeAlloc(T) new T
47 #define OSTypeID(T) T::type_id
49 #include <libkern/c++/OSPtr.h>
51 class Base
: public OSMetaClassBase
{
53 Base() : OSMetaClassBase()
58 class Derived
: public Base
{
65 typedef OSPtr
<Base
> BasePtr
;
66 typedef OSPtr
<Derived
> DerivedPtr
;
68 T_DECL(dumb_osptr
, "Dumb OSPtrs work")
71 T_ASSERT_EQ_PTR(x
, nullptr, NULL
);
72 T_ASSERT_TRUE(typeid(BasePtr
) == typeid(Base
*), NULL
);
73 T_ASSERT_TRUE(typeid(DerivedPtr
) == typeid(Derived
*), NULL
);
75 OSTaggedPtr
<Base
, Base
> y
= nullptr;
76 OSTaggedPtr
<Derived
, Base
> z
= nullptr;
77 T_ASSERT_EQ_PTR(y
, nullptr, NULL
);
78 T_ASSERT_TRUE(typeid(y
) == typeid(Base
*), NULL
);
79 T_ASSERT_TRUE(typeid(z
) == typeid(Derived
*), NULL
);