new test
authorDietmar Maurer <dietmar@mono-cvs.ximian.com>
Thu, 27 Feb 2003 11:52:55 +0000 (11:52 -0000)
committerDietmar Maurer <dietmar@mono-cvs.ximian.com>
Thu, 27 Feb 2003 11:52:55 +0000 (11:52 -0000)
svn path=/trunk/mono/; revision=12024

mono/tests/marshal5.cs [new file with mode: 0644]

diff --git a/mono/tests/marshal5.cs b/mono/tests/marshal5.cs
new file mode 100644 (file)
index 0000000..5a26014
--- /dev/null
@@ -0,0 +1,33 @@
+using System;
+using System.Runtime.InteropServices;
+
+public class Test 
+{
+       [DllImport ("libtest.so", EntryPoint="mono_test_byvalstr_gen")]
+       public static extern IntPtr mono_test_byvalstr_gen();
+
+       [DllImport ("libtest.so", EntryPoint="mono_test_byvalstr_check")]
+       public static extern int mono_test_byvalstr_check(IntPtr data, string correctString);
+       
+       [StructLayout (LayoutKind.Sequential)]
+       public struct ByValStrStruct 
+       {
+               [MarshalAs(UnmanagedType.ByValTStr, SizeConst=100)]
+               public string a;
+       }
+       
+       public unsafe static int Main () 
+       {
+               string testString = "A small string";
+
+               IntPtr udata = mono_test_byvalstr_gen();
+
+               ByValStrStruct data = new ByValStrStruct();
+               data.a = testString;
+
+               Marshal.StructureToPtr(data, udata, false);
+
+               return mono_test_byvalstr_check(udata, testString);
+       }
+}
+