Merge pull request #1624 from esdrubal/getprocesstimes
[mono.git] / mono / tests / pinvoke2.cs
index edf9a6dad4566e205c8a04c0192bfa77fa4b2563..abc81f8d70d77fe44b7a2588b0c7e98d96825339 100644 (file)
@@ -227,6 +227,9 @@ public class Tests {
        [DllImport ("libtest", EntryPoint="mono_test_marshal_out_array")]
        public static extern int mono_test_marshal_out_array ([Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int [] a1, int n);
 
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_out_byref_array_out_size_param")]
+       public static extern int mono_test_marshal_out_byref_array_out_size_param ([Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out int [] a1, out int n);
+
        [DllImport ("libtest", EntryPoint="mono_test_marshal_inout_nonblittable_array", CharSet = CharSet.Unicode)]
        public static extern int mono_test_marshal_inout_nonblittable_array ([In, Out] char [] a1);
        
@@ -293,12 +296,12 @@ public class Tests {
        [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder")]
        public static extern void mono_test_marshal_stringbuilder (StringBuilder sb, int len);
 
-       [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder2")]
-       public static extern void mono_test_marshal_stringbuilder2 (StringBuilder sb, int len);
-
        [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_default")]
        public static extern void mono_test_marshal_stringbuilder_default (StringBuilder sb, int len);
 
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_append")]
+       public static extern void mono_test_marshal_stringbuilder_append (StringBuilder sb, int len);
+
        [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_unicode", CharSet=CharSet.Unicode)]
        public static extern void mono_test_marshal_stringbuilder_unicode (StringBuilder sb, int len);
 
@@ -408,6 +411,19 @@ public class Tests {
                return 0;
        }
 
+       public static int test_0_marshal_out_byref_array_out_size_param () {
+               int [] a1 = null;
+               int len;
+
+               int res = mono_test_marshal_out_byref_array_out_size_param (out a1, out len);
+               if (len != 4)
+                       return 1;
+               for (int i = 0; i < len; i++)
+                       if (a1 [i] != i)
+                               return 2;
+               return 0;
+       }
+
        public static int test_0_marshal_inout_nonblittable_array () {
                char [] a1 = new char [10];
                for (int i = 0; i < 10; i++)
@@ -792,11 +808,33 @@ public class Tests {
                if (res != "This is my message.  Isn't it nice?")
                        return 1;  
 
-               // Test that cached_str is cleared
-               mono_test_marshal_stringbuilder2 (sb, sb.Capacity);
-               res = sb.ToString();
-               if (res != "EFGH")
-                       return 2;
+               // Test StringBuilder with default capacity (16)
+               StringBuilder sb2 = new StringBuilder();
+               mono_test_marshal_stringbuilder_default (sb2, sb2.Capacity);
+               if (sb2.ToString () != "This is my messa")
+                       return 3;
+
+               return 0;
+       }
+
+       public static int test_0_marshal_stringbuilder_append () {
+               const String in_sentinel = "MONO_";
+               const String out_sentinel = "CSHARP_";
+               const int iterations = 100;
+               StringBuilder sb = new StringBuilder(255);
+               StringBuilder check = new StringBuilder(255);
+
+               for (int i = 0; i < iterations; i++) {
+                       sb.Append (in_sentinel[i % in_sentinel.Length]);
+                       check.Append (out_sentinel[i % out_sentinel.Length]);
+
+                       mono_test_marshal_stringbuilder_append (sb, sb.Length);
+
+                       String res = sb.ToString();
+                       String checkRev = check.ToString();
+                       if (res != checkRev)
+                               return 1;
+               }
 
                // Test StringBuilder with default capacity (16)
                StringBuilder sb2 = new StringBuilder();