X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Ftests%2Fpinvoke_ppci.cs;h=34021e0b053a6c99d9728913c67563c442ba996c;hb=e343ad0cfd404c92761cd6e0f683ccd46402897b;hp=db3df3e360072f148d19d2a9115cf8455fc35f30;hpb=d40a434c6052a4a521f674108d3def9c8b829e5a;p=mono.git diff --git a/mono/tests/pinvoke_ppci.cs b/mono/tests/pinvoke_ppci.cs index db3df3e3600..34021e0b053 100644 --- a/mono/tests/pinvoke_ppci.cs +++ b/mono/tests/pinvoke_ppci.cs @@ -10,7 +10,7 @@ // // Bill Seurer (seurer@linux.vnet.ibm.com) // -// (C) {Copyright holder} +// Licensed under the MIT license. See LICENSE file in the project root for full license information. // using System; @@ -20,25 +20,25 @@ using System.Runtime.InteropServices; public class Test_int { [DllImport ("libtest", EntryPoint="mono_return_int1")] - public static extern int mono_return_int1 (int1 s, int addend); + public static extern int1 mono_return_int1 (int1 s, int addend); [StructLayout(LayoutKind.Sequential)] public struct int1 { public int f1; } [DllImport ("libtest", EntryPoint="mono_return_int2")] - public static extern int mono_return_int2 (int2 s, int addend); + public static extern int2 mono_return_int2 (int2 s, int addend); [StructLayout(LayoutKind.Sequential)] public struct int2 { public int f1,f2; } [DllImport ("libtest", EntryPoint="mono_return_int3")] - public static extern int mono_return_int3 (int3 s, int addend); + public static extern int3 mono_return_int3 (int3 s, int addend); [StructLayout(LayoutKind.Sequential)] public struct int3 { public int f1,f2,f3; } [DllImport ("libtest", EntryPoint="mono_return_int4")] - public static extern int mono_return_int4 (int4 s, int addend); + public static extern int4 mono_return_int4 (int4 s, int addend); [StructLayout(LayoutKind.Sequential)] public struct int4 { public int f1,f2,f3,f4; @@ -46,7 +46,7 @@ public class Test_int { // This structure is 1 element too large to use the special return // rules. [DllImport ("libtest", EntryPoint="mono_return_int5")] - public static extern int mono_return_int5 (int5 s, int addend); + public static extern int5 mono_return_int5 (int5 s, int addend); [StructLayout(LayoutKind.Sequential)] public struct int5 { public int f1,f2,f3,f4,f5; @@ -73,41 +73,65 @@ public class Test_int { int1 s1; s1.f1 = 1; - int retval1 = mono_return_int1(s1, 906); - if (retval1 != 2*906) { - Console.WriteLine(" int1 retval1: got {0} but expected {1}", retval1, 2*906); + s1 = mono_return_int1(s1, 906); + if (s1.f1 != 1+906) { + Console.WriteLine(" int1 s1.f1: got {0} but expected {1}", s1.f1, 1+906); return 1; } int2 s2; s2.f1 = 1; s2.f2 = 2; - int retval2 = mono_return_int2(s2, 906); - if (retval2 != 2*906) { - Console.WriteLine(" int2 retval2: got {0} but expected {1}", retval2, 2*906); + s2 = mono_return_int2(s2, 906); + if (s2.f1 != 1+906) { + Console.WriteLine(" int2 s2.f1: got {0} but expected {1}", s2.f1, 1+906); return 1; } + if (s2.f2 != 2+906) { + Console.WriteLine(" int2 s2.f2: got {0} but expected {1}", s2.f2, 2+906); + return 2; + } int3 s3; s3.f1 = 1; s3.f2 = 2; s3.f3 = 3; - int retval3 = mono_return_int3(s3, 906); - if (retval3 != 2*906) { - Console.WriteLine(" int3 retval3: got {0} but expected {1}", retval3, 2*906); + s3 = mono_return_int3(s3, 906); + if (s3.f1 != 1+906) { + Console.WriteLine(" int3 s3.f1: got {0} but expected {1}", s3.f1, 1+906); return 1; } + if (s3.f2 != 2+906) { + Console.WriteLine(" int3 s3.f2: got {0} but expected {1}", s3.f2, 2+906); + return 2; + } + if (s3.f3 != 3+906) { + Console.WriteLine(" int3 s3.f3: got {0} but expected {1}", s3.f3, 3+906); + return 3; + } int4 s4; s4.f1 = 1; s4.f2 = 2; s4.f3 = 3; s4.f4 = 4; - int retval4 = mono_return_int4(s4, 906); - if (retval4 != 2*906) { - Console.WriteLine(" int4 retval4: got {0} but expected {1}", retval4, 2*906); + s4 = mono_return_int4(s4, 906); + if (s4.f1 != 1+906) { + Console.WriteLine(" int4 s4.f1: got {0} but expected {1}", s4.f1, 1+906); return 1; } + if (s4.f2 != 2+906) { + Console.WriteLine(" int4 s4.f2: got {0} but expected {1}", s4.f2, 2+906); + return 2; + } + if (s4.f3 != 3+906) { + Console.WriteLine(" int4 s4.f3: got {0} but expected {1}", s4.f3, 3+906); + return 3; + } + if (s4.f4 != 4+906) { + Console.WriteLine(" int4 s4.f4: got {0} but expected {1}", s4.f4, 4+906); + return 4; + } int5 s5; s5.f1 = 1; @@ -115,18 +139,53 @@ public class Test_int { s5.f3 = 3; s5.f4 = 4; s5.f5 = 5; - int retval5 = mono_return_int5(s5, 906); - if (retval5 != 2*906) { - Console.WriteLine(" int5 retval5: got {0} but expected {1}", retval5, 2*906); + s5 = mono_return_int5(s5, 906); + if (s5.f1 != 1+906) { + Console.WriteLine(" int5 s5.f1: got {0} but expected {1}", s5.f1, 1+906); return 1; } + if (s5.f2 != 2+906) { + Console.WriteLine(" int5 s5.f2: got {0} but expected {1}", s5.f2, 2+906); + return 2; + } + if (s5.f3 != 3+906) { + Console.WriteLine(" int5 s5.f3: got {0} but expected {1}", s5.f3, 3+906); + return 3; + } + if (s5.f4 != 4+906) { + Console.WriteLine(" int5 s5.f4: got {0} but expected {1}", s5.f4, 4+906); + return 4; + } + if (s5.f5 != 5+906) { + Console.WriteLine(" int5 s5.f5: got {0} but expected {1}", s5.f5, 5+906); + return 5; + } + int4_nested sn4; + sn4.nested1.f1 = 1; + sn4.f2 = 2; + sn4.f3 = 3; + sn4.nested2.f4 = 4; + sn4 = mono_return_int4_nested(sn4, 906); + if (sn4.nested1.f1 != 1+906) { + Console.WriteLine(" int4_nested sn4.nested1.f1: got {0} but expected {1}", sn4.nested1.f1, 1+906); + return 1; + } + if (sn4.f2 != 2+906) { + Console.WriteLine(" int4_nested sn4.f2: got {0} but expected {1}", sn4.f2, 2+906); + return 2; + } + if (sn4.f3 != 3+906) { + Console.WriteLine(" int4_nested sn4.f3: got {0} but expected {1}", sn4.f3, 3+906); + return 3; + } + if (sn4.nested2.f4 != 4+906) { + Console.WriteLine(" int4_nested sn4.nested2.f4: got {0} but expected {1}", sn4.nested2.f4, 4+906); + return 4; + } + return 0; } // end Main } // end class Test_int - - - -