Nikolay Sivov : ole32/tests: Add PropVariantCopy() test for BSTR with embedded null.

Alexandre Julliard julliard at winehq.org
Wed Dec 18 15:51:09 CST 2019


Module: wine
Branch: master
Commit: 126cf25617613d282a73e42f357993ea13907de2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=126cf25617613d282a73e42f357993ea13907de2

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Dec 18 12:06:52 2019 +0300

ole32/tests: Add PropVariantCopy() test for BSTR with embedded null.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ole32/tests/propvariant.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/dlls/ole32/tests/propvariant.c b/dlls/ole32/tests/propvariant.c
index 18ecfa6528..2b7e6d7285 100644
--- a/dlls/ole32/tests/propvariant.c
+++ b/dlls/ole32/tests/propvariant.c
@@ -367,6 +367,19 @@ static void test_copy(void)
     hr = PropVariantClear(&propvarDst);
     ok(hr == S_OK, "PropVariantClear(...VT_BSTR...) failed\n");
 
+    /* BSTR with embedded null */
+    propvarSrc.vt = VT_BSTR;
+    U(propvarSrc).bstrVal = SysAllocStringLen(L"Test Str\0ing", 12);
+    hr = PropVariantCopy(&propvarDst, &propvarSrc);
+    ok(hr == S_OK, "Failed to copy propvar, hr %#x.\n", hr);
+    ok(SysStringLen(U(propvarDst).bstrVal) == 8, "Unexpected copy length.\n");
+    ok(SysStringLen(U(propvarSrc).bstrVal) == 12, "Unexpected source length.\n");
+    ok(!lstrcmpW(U(propvarSrc).bstrVal, U(propvarDst).bstrVal), "BSTR not copied properly\n");
+    hr = PropVariantClear(&propvarSrc);
+    ok(hr == S_OK, "Failed to clear propvar, hr %#x.\n", hr);
+    hr = PropVariantClear(&propvarDst);
+    ok(hr == S_OK, "Failed to clear propvar, hr %#x.\n", hr);
+
     propvarSrc.vt = VT_LPWSTR;
     U(propvarSrc).pwszVal = wszTestString;
     hr = PropVariantCopy(&propvarDst, &propvarSrc);




More information about the wine-cvs mailing list