Skip to content

Instantly share code, notes, and snippets.

@kumpera
Created March 19, 2012 19:46
Show Gist options
  • Save kumpera/2125710 to your computer and use it in GitHub Desktop.
Save kumpera/2125710 to your computer and use it in GitHub Desktop.
diff --git a/mono/tests/libtest.c b/mono/tests/libtest.c
index 1a9ee48..bed8db2 100644
--- a/mono/tests/libtest.c
+++ b/mono/tests/libtest.c
@@ -5076,3 +5076,22 @@ mono_test_marshal_call_callback (void)
return callback ();
}
+LIBTEST_API int STDCALL
+mono_test_marshal_lpstr (char *str)
+{
+ return strcmp ("ABC", str);
+}
+
+LIBTEST_API int STDCALL
+mono_test_marshal_lpwstr (gunichar2 *str)
+{
+ char *s;
+ int res;
+
+ s = g_utf16_to_utf8 (str, -1, NULL, NULL, NULL);
+ res = strcmp ("ABC", s);
+ g_free (s);
+
+ return res;
+}
+
diff --git a/mono/tests/pinvoke2.cs b/mono/tests/pinvoke2.cs
index 08a34c0..9103a26 100644
--- a/mono/tests/pinvoke2.cs
+++ b/mono/tests/pinvoke2.cs
@@ -1646,5 +1646,30 @@ public class Tests {
else
return 2;
}
+
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_lpstr")]
+ public static extern int mono_test_marshal_lpstr ([MarshalAs(UnmanagedType.LPStr)] string str);
+
+ public static int test_0_mono_test_marshal_lpstr () {
+ string str = "ABC";
+
+ if (mono_test_marshal_lpstr (str) != 0)
+ return 1;
+
+ return 0;
+ }
+
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_lpwstr")]
+ public static extern int mono_test_marshal_lpwstr ([MarshalAs(UnmanagedType.LPWStr)] string str);
+
+ public static int test_0_mono_test_marshal_lpwstr () {
+ string str = "ABC";
+
+ if (mono_test_marshal_lpwstr (str) != 0)
+ return 1;
+
+ return 0;
+ }
+
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment