[runtime] Fix DISABLE_REFLECTION_EMIT build.
[mono.git] / mono / tests / marshal5.cs
index 63512171dae4ebb28697e2f72c3884c84c2e9844..f35d8f9e25cec0d0f65dc6fcc71d1886de234c07 100644 (file)
@@ -8,6 +8,9 @@ public class Test
 
        [DllImport ("libtest", EntryPoint="mono_test_byvalstr_check")]
        public static extern int mono_test_byvalstr_check(IntPtr data, string correctString);
+
+       [DllImport ("libtest", EntryPoint="mono_test_byvalstr_check_unicode")]
+       public static extern int mono_test_byvalstr_check_unicode(ref ByValStrStruct_Unicode var, int test);
        
        [StructLayout (LayoutKind.Sequential)]
        public struct ByValStrStruct 
@@ -15,6 +18,15 @@ public class Test
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst=100)]
                public string a;
        }
+
+       [StructLayout (LayoutKind.Sequential, CharSet=CharSet.Unicode)]
+       public struct ByValStrStruct_Unicode
+       {
+               [MarshalAs(UnmanagedType.ByValTStr, SizeConst=4)]
+               public string a;
+
+               public int flag;
+       }
        
        public unsafe static int Main () 
        {
@@ -27,7 +39,28 @@ public class Test
 
                Marshal.StructureToPtr(data, udata, false);
 
-               return mono_test_byvalstr_check(udata, testString);
+               int c = mono_test_byvalstr_check(udata, testString);
+               if (c != 0)
+                       return 1;
+
+               ByValStrStruct_Unicode a = new ByValStrStruct_Unicode ();
+               a.flag = 0x1234abcd;
+               a.a = "1234";
+               c = mono_test_byvalstr_check_unicode (ref a, 1);
+               if (c != 0)
+                       return 2;
+
+               a.a = "12";
+               c = mono_test_byvalstr_check_unicode (ref a, 2);
+               if (c != 0)
+                       return 3;
+
+               a.a = "1234567890";
+               c = mono_test_byvalstr_check_unicode (ref a, 3);
+               if (c != 0)
+                       return 4;
+
+               return 0;
        }
 }