[PATCH] ole32/tests: Move stream creation to test function that's using it

Nikolay Sivov nsivov at codeweavers.com
Wed Jan 31 00:41:30 CST 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/ole32/tests/hglobalstream.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/dlls/ole32/tests/hglobalstream.c b/dlls/ole32/tests/hglobalstream.c
index e20d81b8b0..6a0498aa60 100644
--- a/dlls/ole32/tests/hglobalstream.c
+++ b/dlls/ole32/tests/hglobalstream.c
@@ -43,16 +43,20 @@ do { \
         } \
 } while(0)
 
-static void test_streamonhglobal(IStream *pStream)
+static void test_streamonhglobal(void)
 {
     const char data[] = "Test String";
     ULARGE_INTEGER ull;
+    IStream *pStream;
     LARGE_INTEGER ll;
     char buffer[128];
     ULONG read;
     STATSTG statstg;
     HRESULT hr;
 
+    hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
+    ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr);
+
     ull.QuadPart = sizeof(data);
     hr = IStream_SetSize(pStream, ull);
     ok_ole_success(hr, "IStream_SetSize");
@@ -293,6 +297,8 @@ static void test_streamonhglobal(IStream *pStream)
     hr = IStream_SetSize(pStream, ull);
     ok(hr == E_OUTOFMEMORY || broken(hr == S_OK), /* win9x */
        "IStream_SetSize with large size should have returned E_OUTOFMEMORY instead of 0x%08x\n", hr);
+
+    IStream_Release(pStream);
 }
 
 static HRESULT WINAPI TestStream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
@@ -510,14 +516,7 @@ static void test_freed_hglobal(void)
 
 START_TEST(hglobalstream)
 {
-    HRESULT hr;
-    IStream *pStream;
-
-    hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
-    ok_ole_success(hr, "CreateStreamOnHGlobal");
-
-    test_streamonhglobal(pStream);
-    IStream_Release(pStream);
+    test_streamonhglobal();
     test_copyto();
     test_freed_hglobal();
 }
-- 
2.15.1




More information about the wine-devel mailing list