Remove some junk I left by accident
[mono.git] / mono / tests / marshal7.cs
index 40b7d26a873e8ce04fa97423703441fc414c7d8e..aeb7b55c873d1eb2d7a46f152a9166c18463087d 100644 (file)
@@ -12,16 +12,88 @@ public class Test
        [StructLayout(LayoutKind.Sequential, Size=32)]
        public class TestStruct2 
        {
-               [MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)]\r
-               public string   a;\r
+               [MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)]
+               public string   a;
                public int              b;
-       }\r
-\r
+       }
+
        [StructLayout(LayoutKind.Sequential, Size=32)]
        public class TestStruct3 : TestStruct2
        {
                public int              c;
-       }\r
+       }
+
+       [StructLayout (LayoutKind.Sequential)]
+       public class TestStruct4
+       {
+               [MarshalAs (UnmanagedType.Interface)]
+               object itf;
+       }
+
+       [StructLayout (LayoutKind.Sequential)]
+       public class TestStruct5
+       {
+               [MarshalAs (UnmanagedType.IUnknown)]
+               object itf;
+       }
+
+       [StructLayout (LayoutKind.Sequential)]
+       public class TestStruct6
+       {
+               [MarshalAs (UnmanagedType.IDispatch)]
+               object itf;
+       }
+
+       [StructLayout (LayoutKind.Sequential)]
+       public class TestStruct7
+       {
+               [MarshalAs (UnmanagedType.Struct)]
+               object itf;
+       }
+
+       // Size should be 12 in both 32 and 64 bits
+       [StructLayout (LayoutKind.Explicit)]
+       struct TestStruct8 {
+               [FieldOffset (0)]
+               public int a;
+               [FieldOffset (4)]
+               public ulong b;
+       }
+
+       // Size should be 12 in both 32 and 64 bits
+       [StructLayout (LayoutKind.Explicit, Size=12)]
+       struct TestStruct9 {
+               [FieldOffset (0)]
+               public int a;
+               [FieldOffset (4)]
+               public ulong b;
+       }
+
+       // Size should be 11 in both 32 and 64 bits
+       [StructLayout (LayoutKind.Explicit)]
+       struct TestStruct10 {
+               [FieldOffset (0)]
+               public int a;
+               [FieldOffset (3)]
+               public ulong b;
+       }
+
+       // Size should be 11 in both 32 and 64 bits
+       [StructLayout (LayoutKind.Explicit, Size=11)]
+       struct TestStruct11 {
+               [FieldOffset (0)]
+               public int a;
+               [FieldOffset (3)]
+               public ulong b;
+       }
+
+       [StructLayout (LayoutKind.Explicit, Pack=1)]
+       struct TestStruct12 {
+               [FieldOffset (0)]
+               public short a;
+               [FieldOffset (2)]
+               public int b;
+       }
 
        public unsafe static int Main () 
        {
@@ -88,17 +160,37 @@ public class Test
                ///
                ///     Also make sure OffsetOf returns the correct Exception.
                ///
-               try {\r
-                       Marshal.OffsetOf(testType3, "blah");\r
-                       return 8;\r
+               try {
+                       Marshal.OffsetOf(testType3, "blah");
+                       return 8;
                }
-               catch(ArgumentException e)  {\r
-                       /// Way to go :)\r
+               catch(ArgumentException e)  {
+                       /// Way to go :)
                }
-               catch(Exception e) {\r
-                       return 9;\r
+               catch(Exception e) {
+                       return 9;
                }
 
+               // test size of structs with objects
+               if (Marshal.SizeOf (typeof (TestStruct4)) != IntPtr.Size)
+                       return 10;
+               if (Marshal.SizeOf (typeof (TestStruct5)) != IntPtr.Size)
+                       return 11;
+               if (Marshal.SizeOf (typeof (TestStruct6)) != IntPtr.Size)
+                       return 12;
+               // a VARIANT is 
+               if (Marshal.SizeOf (typeof (TestStruct7)) != 16)
+                       return 13;
+               if (Marshal.SizeOf (typeof (TestStruct8)) != 16)
+                       return 14;
+               if (Marshal.SizeOf (typeof (TestStruct9)) != 12)
+                       return 15;
+               if (Marshal.SizeOf (typeof (TestStruct10)) != 16)
+                       return 16;
+               if (Marshal.SizeOf (typeof (TestStruct11)) != 11)
+                       return 17;
+               if (Marshal.SizeOf (typeof (TestStruct12)) != 6)
+                       return 18;
                return 0;
        }
 }