Author: miguel
Date: 2007-01-01 22:44:42 -0500 (Mon, 01 Jan 2007)
New Revision: 70333
Modified:
trunk/mono/mono/tests/ChangeLog
trunk/mono/mono/tests/libtest.c
trunk/mono/mono/tests/marshal5.cs
Log:
2007-01-01 Miguel de Icaza <[EMAIL PROTECTED]>
* libtest.c, marshal5.cs: Add tests for ByValTStr marshalling when
the charset is Unicode (see bugs 79944 and 78722).
Modified: trunk/mono/mono/tests/ChangeLog
===================================================================
--- trunk/mono/mono/tests/ChangeLog 2007-01-02 02:51:03 UTC (rev 70332)
+++ trunk/mono/mono/tests/ChangeLog 2007-01-02 03:44:42 UTC (rev 70333)
@@ -1,3 +1,8 @@
+2007-01-01 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * libtest.c, marshal5.cs: Add tests for ByValTStr marshalling when
+ the charset is Unicode (see bugs 79944 and 78722).
+
2006-12-31 Miguel de Icaza <[EMAIL PROTECTED]>
* exists.cs: Add new test case for MONO_IOMAP bug.
Modified: trunk/mono/mono/tests/libtest.c
===================================================================
--- trunk/mono/mono/tests/libtest.c 2007-01-02 02:51:03 UTC (rev 70332)
+++ trunk/mono/mono/tests/libtest.c 2007-01-02 03:44:42 UTC (rev 70333)
@@ -985,7 +985,41 @@
return (ret != 0);
}
+typedef struct {
+ char a[8];
+ int flag;
+} ByValStrStruct_Unicode;
+
STDCALL int
+mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test)
+{
+ if (ref->flag != 0x1234abcd){
+ printf ("overwritten data");
+ return 1;
+ }
+
+ if (test == 1 || test == 3){
+ if (ref->a [0] != '1' ||
+ ref->a [1] != 0 ||
+ ref->a [2] != '2' ||
+ ref->a [3] != 0 ||
+ ref->a [4] != '3' ||
+ ref->a [5] != 0)
+ return 1;
+ return 0;
+ }
+ if (test == 2){
+ if (ref->a [0] != '1' ||
+ ref->a [1] != 0 ||
+ ref->a [2] != '2' ||
+ ref->a [3] != 0)
+ return 1;
+ return 0;
+ }
+ return 10;
+}
+
+STDCALL int
NameManglingAnsi (char *data)
{
return data [0] + data [1] + data [2];
Modified: trunk/mono/mono/tests/marshal5.cs
===================================================================
--- trunk/mono/mono/tests/marshal5.cs 2007-01-02 02:51:03 UTC (rev 70332)
+++ trunk/mono/mono/tests/marshal5.cs 2007-01-02 03:44:42 UTC (rev 70333)
@@ -8,6 +8,9 @@
[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 @@
[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 @@
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;
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches