summaryrefslogtreecommitdiff
path: root/tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2017-06-13 18:47:36 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2017-06-13 18:47:36 +0900
commit61d6a817e39d3bae0f47dbc09838d51db22a5d30 (patch)
treecb37caa1784bc738b976273335d6ed04a7cc80b0 /tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs
parent5b975f8233e8c8d17b215372f89ca713b45d6a0b (diff)
downloadcoreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.gz
coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.bz2
coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.zip
Imported Upstream version 2.0.0.11992upstream/2.0.0.11992
Diffstat (limited to 'tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs')
-rw-r--r--tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs b/tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs
index 714dac83e4..29ee83a8c0 100644
--- a/tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs
+++ b/tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs
@@ -52,6 +52,39 @@ public class StringMarshalingTest
}
}
+ private unsafe void SecureStringToBSTRToString()
+ {
+ foreach (String ts in TestStrings)
+ {
+ SecureString secureString = new SecureString();
+ foreach (char character in ts)
+ {
+ secureString.AppendChar(character);
+ }
+
+ IntPtr BStr = IntPtr.Zero;
+ String str;
+
+ try
+ {
+ BStr = Marshal.SecureStringToBSTR(secureString);
+ str = Marshal.PtrToStringBSTR(BStr);
+ }
+ finally
+ {
+ if (BStr != IntPtr.Zero)
+ {
+ Marshal.ZeroFreeBSTR(BStr);
+ }
+ }
+
+ if (!str.Equals(ts))
+ {
+ throw new Exception();
+ }
+ }
+ }
+
private void StringToCoTaskMemAnsiToString()
{
foreach (String ts in TestStrings)
@@ -201,6 +234,7 @@ public class StringMarshalingTest
public bool RunTests()
{
StringToBStrToString();
+ SecureStringToBSTRToString();
StringToCoTaskMemAnsiToString();
StringToCoTaskMemUniToString();
StringToHGlobalAnsiToString();