On 10/18/07, Paolo Molaro <[EMAIL PROTECTED]> wrote: > You need to also add a test case to the test suite to exercise the new > code.
Here are the tests for my previous commit. OK to commit? -bill
Index: mono/mono/tests/pinvoke2.cs =================================================================== --- mono/mono/tests/pinvoke2.cs (revision 87787) +++ mono/mono/tests/pinvoke2.cs (working copy) @@ -157,6 +157,24 @@ [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_byref")] public static extern int mono_test_marshal_bool_byref (int a, ref bool b, int c); + [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_in_as_I1_U1")] + public static extern int mono_test_marshal_bool_in_as_I1 ([MarshalAs (UnmanagedType.I1)] bool bTrue, [MarshalAs (UnmanagedType.I1)] bool bFalse); + + [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_in_as_I1_U1")] + public static extern int mono_test_marshal_bool_in_as_U1 ([MarshalAs (UnmanagedType.U1)] bool bTrue, [MarshalAs (UnmanagedType.U1)] bool bFalse); + + [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_out_as_I1_U1")] + public static extern int mono_test_marshal_bool_out_as_I1 ([MarshalAs (UnmanagedType.I1)] out bool bTrue, [MarshalAs (UnmanagedType.I1)] out bool bFalse); + + [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_out_as_I1_U1")] + public static extern int mono_test_marshal_bool_out_as_U1 ([MarshalAs (UnmanagedType.U1)] out bool bTrue, [MarshalAs (UnmanagedType.U1)] out bool bFalse); + + [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_ref_as_I1_U1")] + public static extern int mono_test_marshal_bool_ref_as_I1 ([MarshalAs (UnmanagedType.I1)] ref bool bTrue, [MarshalAs (UnmanagedType.I1)] ref bool bFalse); + + [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_ref_as_I1_U1")] + public static extern int mono_test_marshal_bool_ref_as_U1 ([MarshalAs (UnmanagedType.U1)] ref bool bTrue, [MarshalAs (UnmanagedType.U1)] ref bool bFalse); + [DllImport ("libtest", EntryPoint="mono_test_marshal_array")] public static extern int mono_test_marshal_array (int [] a1); @@ -619,6 +637,62 @@ return 0; } + public static int test_0_marshal_bool_as_I1 () { + + int ret; + bool bTrue, bFalse; + if ((ret = mono_test_marshal_bool_in_as_I1 (true, false)) != 0) + return ret; + + if ((ret = mono_test_marshal_bool_out_as_I1 (out bTrue, out bFalse)) != 0) + return ret; + + if(!bTrue) + return 10; + + if(bFalse) + return 11; + + if ((ret = mono_test_marshal_bool_ref_as_I1 (ref bTrue, ref bFalse)) != 0) + return ret; + + if(bTrue) + return 12; + + if(!bFalse) + return 13; + + return 0; + } + + public static int test_0_marshal_bool_as_U1 () { + + int ret; + bool bTrue, bFalse; + if ((ret = mono_test_marshal_bool_in_as_U1 (true, false)) != 0) + return ret; + + if ((ret = mono_test_marshal_bool_out_as_U1 (out bTrue, out bFalse)) != 0) + return ret; + + if(!bTrue) + return 10; + + if(bFalse) + return 11; + + if ((ret = mono_test_marshal_bool_ref_as_U1 (ref bTrue, ref bFalse)) != 0) + return ret; + + if(bTrue) + return 12; + + if(!bFalse) + return 13; + + return 0; + } + public static int test_0_return_vtype () { SimpleStruct ss = mono_test_return_vtype (new IntPtr (5)); Index: mono/mono/tests/ChangeLog =================================================================== --- mono/mono/tests/ChangeLog (revision 87787) +++ mono/mono/tests/ChangeLog (working copy) @@ -1,3 +1,10 @@ +2007-10-18 William Holmes <[EMAIL PROTECTED]> + + * pinvoke2.cs, libtest.c Adding test cases for marshaling + booleans as I1 and U1. Tests commit r87725. + + Code is contributed under MIT/X11 license. + 2007-10-17 Mark Probst <[EMAIL PROTECTED]> * bug-331798-tb.2.cs: added for Rodrigo Index: mono/mono/tests/libtest.c =================================================================== --- mono/mono/tests/libtest.c (revision 87787) +++ mono/mono/tests/libtest.c (working copy) @@ -252,6 +252,45 @@ return res; } +STDCALL int +mono_test_marshal_bool_in_as_I1_U1 (char bTrue, char bFalse) +{ + if (!bTrue) + return 1; + if (bFalse) + return 2; + return 0; +} + +STDCALL int +mono_test_marshal_bool_out_as_I1_U1 (char* bTrue, char* bFalse) +{ + if (!bTrue || !bFalse) + return 3; + + *bTrue = 1; + *bFalse = 0; + + return 0; +} + +STDCALL int +mono_test_marshal_bool_ref_as_I1_U1 (char* bTrue, char* bFalse) +{ + if (!bTrue || !bFalse) + return 4; + + if (!(*bTrue)) + return 5; + if (*bFalse) + return 6; + + *bFalse = 1; + *bTrue = 0; + + return 0; +} + STDCALL int mono_test_marshal_array (int *a1) {
_______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list