added more pinvoke test methods
[mono.git] / mono / tests / pinvoke.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 public class Test {
5
6         [DllImport("cygwin1.dll", EntryPoint="puts", CharSet=CharSet.Ansi)]
7         public static extern int puts (string name);
8
9         [DllImport ("libtest.so", EntryPoint="mono_test_many_int_arguments")]
10         public static extern int mono_test_many_int_arguments (int a, int b, int c, int d, int e,
11                                                                int f, int g, int h, int i, int j);
12         [DllImport ("libtest.so", EntryPoint="mono_test_many_short_arguments")]
13         public static extern int mono_test_many_short_arguments (short a, short b, short c, short d, short e,
14                                                                  short f, short g, short h, short i, short j);
15         [DllImport ("libtest.so", EntryPoint="mono_test_many_byte_arguments")]
16         public static extern int mono_test_many_byte_arguments (byte a, byte b, byte c, byte d, byte e,
17                                                                 byte f, byte g, byte h, byte i, byte j);
18
19         public static int Main () {
20                 puts ("A simple Test for PInvoke");
21                 
22                 if (Math.Cos (Math.PI) != -1)
23                         return 1;
24                 if (Math.Acos (1) != 0)
25                         return 1;
26                 if (mono_test_many_int_arguments (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) != 10)
27                         return 1;
28                 if (mono_test_many_short_arguments (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) != 55)
29                         return 1;
30                 if (mono_test_many_byte_arguments (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) != 55)
31                         return 1;
32                 
33                 return 0;
34         }
35 }