Beispiel #1
0
        public void Blocks()
        {
            int    i = 0;
            string b = null;
            NSSet  s = new NSSet("a", "b", "c");

            s.Enumerate(delegate(NSObject obj, ref bool stop) {
                stop = i++ == 1;
                b    = obj.ToString();
            });
            // test behavior (we did not break anything)
            Assert.AreEqual("b", b, "Stop");
            // test that BlockLiteral is fully preserved
            int size = Marshal.SizeOf(typeof(BlockLiteral));               // e.g. unused 'reserved' must not be removed

            Assert.AreEqual(IntPtr.Size == 8 ? 48 : 28, size, "BlockLiteral size");
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            NSApplication.Init();

            Test.EnsureLinker(true);

            int    i = 0;
            string b = null;
            NSSet  s = new NSSet("a", "b", "c");

            s.Enumerate(delegate(NSObject obj, ref bool stop) {
                stop = i++ == 1;
                b    = obj.ToString();
            });
            // test behavior (we did not break anything)
            Test.Log.WriteLine("[{0}]\tBehavior: Stop at item '{1}'", b == "b" ? "PASS" : "FAIL", b);
            // test that BlockLiteral is fully preserved
            int size = Marshal.SizeOf(typeof(BlockLiteral));               // e.g. unused 'reserved' must not be removed

            Test.Log.WriteLine("[{0}]\tBlockLiteral is {1} bytes", size == 28 ? "PASS" : "FAIL", size);

            Test.Terminate();
        }