2009-11-20 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mono / tests / pinvoke3.cs
index f506fe3184d6b2bc915837d23c0c08ed2d2e52df..ec2250839d3c9bae8a6175b020bd2b24010d5bd3 100644 (file)
@@ -861,6 +861,30 @@ public class Tests {
                return mono_test_marshal_array_delegate8 (arr, 2, new ArrayDelegate8 (array_delegate8));
        }
 
+       /* Array with size param of type long */
+
+       public delegate int ArrayDelegate8_2 (long i, 
+                                                                               string j, 
+                                                                               [In, MarshalAs(UnmanagedType.LPArray, 
+                                                                                                          ArraySubType=UnmanagedType.LPStr, SizeParamIndex=0)] string[] arr);
+
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate_long")]
+       public static extern int mono_test_marshal_array_delegate8_2 (string[] arr, long len, ArrayDelegate8_2 d);
+
+       public static int array_delegate8_2 (long i, string j, string[] arr) {
+               if (arr.Length != 2)
+                       return 1;
+               if ((arr [0] != "ABC") || (arr [1] != "DEF"))
+                       return 2;
+               return 0;
+       }
+
+       public static int test_0_marshal_array_delegate_long_param () { 
+               string[] arr = new string [] { "ABC", "DEF" };
+               return mono_test_marshal_array_delegate8_2 (arr, arr.Length, new ArrayDelegate8_2 (array_delegate8_2));
+       }
+
+
        /*
         * [Out] blittable arrays
         */
@@ -986,4 +1010,24 @@ public class Tests {
                return mono_test_marshal_return_string_array_delegate (new ReturnArrayDelegate (return_array_delegate_null));
        }
 
+       /*
+        * Byref string marshalling
+        */
+       public delegate int ByrefStringDelegate (ref string s);
+
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_string_delegate")]
+       public static extern int mono_test_marshal_byref_string_delegate (ByrefStringDelegate d);
+
+       public static int byref_string_delegate (ref string s) {
+               if (s != "ABC")
+                       return 1;
+
+               s = "DEF";
+
+               return 0;
+       }
+
+       public static int test_0_marshal_byref_string_delegate () {     
+               return mono_test_marshal_byref_string_delegate (new ByrefStringDelegate (byref_string_delegate));
+       }
 }