Add an unsafe section to the code that's using direct pointers. This
[mono.git] / mono / tests / pinvoke15.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 class Test {
5         
6         [DllImport ("libtest")]
7         static extern int string_marshal_test0 (string str);
8
9         [DllImport ("libtest")]
10         static extern void string_marshal_test1 (out string str);
11
12         [DllImport ("libtest")]
13         static extern int string_marshal_test2 (ref string str);
14
15         [DllImport ("libtest")]
16         static extern int string_marshal_test3 (string str);
17
18         static int Main ()
19         {
20                 if (string_marshal_test0 ("TEST0") != 0)
21                         return 1;
22
23                 string res;
24                 
25                 string_marshal_test1 (out res);
26
27                 if (res != "TEST1")
28                         return 2;
29                 
30                 if (string_marshal_test2 (ref res) != 0)
31                         return 3;
32
33                 if (string_marshal_test3 (null) != 0)
34                         return 4;
35
36
37                 return 0;
38         }
39 }