Beispiel #1
0
        private static IntPtr CreateNativeObject()
        {
            var foo = new NSString("foo");

            foo.DangerousRetain();
            return(foo.Handle);
        }
Beispiel #2
0
        public void TestFromHandle_owns(bool owns)
        {
            const string testString = "a random and long string that should not be cached by the OS";

            using var str = new NSString(testString);
            for (var i = 0; i < 100; i++)
            {
                if (owns)
                {
                    str.DangerousRetain();
                }
                Assert.AreEqual(testString, NSString.FromHandle(str.Handle, owns), $"true #{i}");
            }
            // If there was a leak, RetainCount would be 100+ because we looped 100 times above.
            Assert.That(str.RetainCount, Is.LessThan((nuint)10), "RetainCount");
        }