2007-10-19 Marek Habersack <mhabersack@novell.com>
[mono.git] / mono / tests / pinvoke3.cs
index a55e9a571583731bf0cf1676378cc526e691c688..981f542968455794f54d8d14c3ba8c2a7ef261e2 100644 (file)
@@ -848,4 +848,75 @@ public class Tests {
                return mono_test_marshal_out_string_array_delegate (arr, 2, new ArrayDelegate10 (array_delegate10));
        }
 
+       /*
+        * [In, Out] classes
+        */
+
+       public delegate int InOutByvalClassDelegate ([In, Out] SimpleClass ss);
+
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_inout_byval_class_delegate")]
+       public static extern int mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate d);
+
+       public static int delegate_test_byval_class_inout (SimpleClass ss) {
+               if ((ss.a != false) || (ss.b != true) || (ss.c != false) || (ss.d != "FOO"))
+                       return 1;
+
+               ss.a = true;
+               ss.b = false;
+               ss.c = true;
+               ss.d = "RES";
+
+               return 0;
+       }
+
+       public static int test_0_marshal_inout_byval_class_delegate () {
+               return mono_test_marshal_inout_byval_class_delegate (new InOutByvalClassDelegate (delegate_test_byval_class_inout));
+       }
+
+       /*
+        * Returning unicode strings
+        */
+       [return: MarshalAs(UnmanagedType.LPWStr)]
+       public delegate string ReturnUnicodeStringDelegate([MarshalAs(UnmanagedType.LPWStr)] string message);
+
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_return_unicode_string_delegate")]
+       public static extern int mono_test_marshal_return_unicode_string_delegate (ReturnUnicodeStringDelegate d);
+
+       public static String return_unicode_string_delegate (string message) {
+               return message;
+       }
+
+       public static int test_0_marshal_return_unicode_string_delegate () {    
+               return mono_test_marshal_return_unicode_string_delegate (new ReturnUnicodeStringDelegate (return_unicode_string_delegate));
+       }
+
+       /*
+        * Returning string arrays
+        */
+       public delegate string[] ReturnArrayDelegate (int i);
+
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_return_string_array_delegate")]
+       public static extern int mono_test_marshal_return_string_array_delegate (ReturnArrayDelegate d);
+
+       public static String[] return_array_delegate (int i) {
+               String[] arr = new String [2];
+
+               arr [0] = "ABC";
+               arr [1] = "DEF";
+
+               return arr;
+       }
+
+       public static String[] return_array_delegate_null (int i) {
+               return null;
+       }
+
+       public static int test_0_marshal_return_string_array_delegate () {      
+               return mono_test_marshal_return_string_array_delegate (new ReturnArrayDelegate (return_array_delegate));
+       }
+
+       public static int test_3_marshal_return_string_array_delegate_null () { 
+               return mono_test_marshal_return_string_array_delegate (new ReturnArrayDelegate (return_array_delegate_null));
+       }
+
 }