* StringTest.cs: Added test for Concat when one of the arguments is an
[mono.git] / mono / tests / marshal4.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 public class Test {
5
6         [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate_struct")]
7         public static extern int mono_test_marshal_delegate_struct (DelegateStruct s);
8
9         public delegate int WndProc (int a);
10
11         public static int test_func (int a)
12         {
13                 return a;
14         }
15         
16         [StructLayout (LayoutKind.Sequential)]
17         public struct DelegateStruct {
18                 public int a;
19                 public WndProc func;
20         }
21         
22         public unsafe static int Main () {
23                 DelegateStruct ss = new DelegateStruct ();
24                 int size = Marshal.SizeOf (typeof (DelegateStruct));
25                 
26                 Console.WriteLine ("DelegateStruct:" + size);
27                 if (size != 2 * sizeof(void *)) // not right for 64 bit pointers which can be 4 byte aligned
28                         return 1;
29                 
30                 ss.a = 123;
31                 ss.func = new WndProc(test_func);
32
33                 if (mono_test_marshal_delegate_struct (ss) != 123)
34                         return 1;
35                 
36                 return 0;
37         }
38 }
39