Author: zoltan
Date: 2005-05-12 16:29:45 -0400 (Thu, 12 May 2005)
New Revision: 44464
Modified:
trunk/mono/mono/tests/ChangeLog
trunk/mono/mono/tests/libtest.c
trunk/mono/mono/tests/marshal9.cs
Log:
2005-05-12 Zoltan Varga <[EMAIL PROTECTED]>
* marshal9.cs libtest.c: Add more tests.
Modified: trunk/mono/mono/tests/ChangeLog
===================================================================
--- trunk/mono/mono/tests/ChangeLog 2005-05-12 20:29:08 UTC (rev 44463)
+++ trunk/mono/mono/tests/ChangeLog 2005-05-12 20:29:45 UTC (rev 44464)
@@ -1,5 +1,7 @@
2005-05-12 Zoltan Varga <[EMAIL PROTECTED]>
+ * marshal9.cs libtest.c: Add more tests.
+
* pinvoke3.cs libtest.c: Add test for [Out] marshalling of arrays.
Fix warnings.
Modified: trunk/mono/mono/tests/libtest.c
===================================================================
--- trunk/mono/mono/tests/libtest.c 2005-05-12 20:29:08 UTC (rev 44463)
+++ trunk/mono/mono/tests/libtest.c 2005-05-12 20:29:45 UTC (rev 44464)
@@ -1329,6 +1329,14 @@
}
STDCALL void*
+mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
+{
+ g_assert_not_reached ();
+
+ return NULL;
+}
+
+STDCALL void*
mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
{
g_assert (ptr == NULL);
Modified: trunk/mono/mono/tests/marshal9.cs
===================================================================
--- trunk/mono/mono/tests/marshal9.cs 2005-05-12 20:29:08 UTC (rev 44463)
+++ trunk/mono/mono/tests/marshal9.cs 2005-05-12 20:29:45 UTC (rev 44464)
@@ -163,4 +163,109 @@
return res == 15 ? 0 : 3;
}
+ /*
+ * Test custom marshaller class not implementing ICustomMarshaler
+ */
+
+ public class Marshal2 {
+ }
+
+ [DllImport ("libtest")]
+ private static extern IntPtr mono_test_marshal_pass_return_custom2 (int
i,
+
[MarshalAs(
UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Marshal3),
MarshalCookie = "5")] object number, int j);
+
+ public static int test_0_not_icustommarshaller () {
+ try {
+ mono_test_marshal_pass_return_custom2 (5, 10, 5);
+ }
+ catch (ApplicationException) {
+ return 0;
+ }
+ return 1;
+ }
+
+
+ /*
+ * Test custom marshaller class missing GetInstance method
+ */
+
+ public class Marshal3 : ICustomMarshaler {
+ public void CleanUpManagedData (object managedObj)
+ {
+ }
+
+ public void CleanUpNativeData (IntPtr pNativeData)
+ {
+ }
+
+ public int GetNativeDataSize ()
+ {
+ return 4;
+ }
+
+ public IntPtr MarshalManagedToNative (object managedObj)
+ {
+ return IntPtr.Zero;
+ }
+
+ public object MarshalNativeToManaged (IntPtr pNativeData)
+ {
+ return null;
+ }
+ }
+
+ public class Marshal4 : Marshal3 {
+ public static object GetInstance (string s) {
+ return null;
+ }
+ }
+
+ public class Marshal5 : Marshal3 {
+ public static ICustomMarshaler GetInstance (object s) {
+ return null;
+ }
+ }
+
+ [DllImport ("libtest", EntryPoint =
"mono_test_marshal_pass_return_custom2")]
+ private static extern IntPtr mono_test_marshal_pass_return_custom3 (int
i,
+
[MarshalAs(
UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Marshal3),
MarshalCookie = "5")] object number, int j);
+
+ [DllImport ("libtest", EntryPoint =
"mono_test_marshal_pass_return_custom2")]
+ private static extern IntPtr mono_test_marshal_pass_return_custom4 (int
i,
+
[MarshalAs(
UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Marshal4),
MarshalCookie = "5")] object number, int j);
+
+ [DllImport ("libtest", EntryPoint =
"mono_test_marshal_pass_return_custom2")]
+ private static extern IntPtr mono_test_marshal_pass_return_custom5 (int
i,
+
[MarshalAs(
UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Marshal5),
MarshalCookie = "5")] object number, int j);
+
+ public static int test_0_missing_getinstance1 () {
+ try {
+ mono_test_marshal_pass_return_custom3 (5, 10, 5);
+ }
+ catch (ApplicationException) {
+ return 0;
+ }
+ return 1;
+ }
+
+ public static int test_0_missing_getinstance2 () {
+ try {
+ mono_test_marshal_pass_return_custom4 (5, 10, 5);
+ }
+ catch (ApplicationException) {
+ return 0;
+ }
+ return 1;
+ }
+
+ public static int test_0_missing_getinstance3 () {
+ try {
+ mono_test_marshal_pass_return_custom5 (5, 10, 5);
+ }
+ catch (ApplicationException) {
+ return 0;
+ }
+ return 1;
+ }
+
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches