]> git.saurik.com Git - apple/xnu.git/blobdiff - tests/intrusive_shared_ptr_src/ctor.default.cpp
xnu-7195.50.7.100.1.tar.gz
[apple/xnu.git] / tests / intrusive_shared_ptr_src / ctor.default.cpp
diff --git a/tests/intrusive_shared_ptr_src/ctor.default.cpp b/tests/intrusive_shared_ptr_src/ctor.default.cpp
new file mode 100644 (file)
index 0000000..613cf9c
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// Tests for
+//  intrusive_shared_ptr();
+//
+
+#include <libkern/c++/intrusive_shared_ptr.h>
+#include <darwintest.h>
+#include <darwintest_utils.h>
+#include "test_policy.h"
+
+struct T { int i; };
+
+template <typename T>
+static void
+tests()
+{
+       {
+               libkern::intrusive_shared_ptr<T, test_policy> ptr;
+               CHECK(ptr.get() == nullptr);
+       }
+       {
+               libkern::intrusive_shared_ptr<T, test_policy> ptr{};
+               CHECK(ptr.get() == nullptr);
+       }
+       {
+               libkern::intrusive_shared_ptr<T, test_policy> ptr = libkern::intrusive_shared_ptr<T, test_policy>();
+               CHECK(ptr.get() == nullptr);
+       }
+       {
+               libkern::intrusive_shared_ptr<T, test_policy> ptr = {};
+               CHECK(ptr.get() == nullptr);
+       }
+}
+
+T_DECL(ctor_default, "intrusive_shared_ptr.ctor.default") {
+       tests<T>();
+}