kernel32/tests: Add a test to check some fields in fake dlls.
[wine.git] / dlls / ole32 / tests / hglobalstream.c
blob6a0498aa60b099683cd52504e05b410f87915961
1 /*
2 * Stream on HGLOBAL Tests
4 * Copyright 2006 Robert Shearman (for CodeWeavers)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "objbase.h"
29 #include "wine/test.h"
31 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
33 static char const * const *expected_method_list;
35 #define CHECK_EXPECTED_METHOD(method_name) \
36 do { \
37 ok(*expected_method_list != NULL, "Extra method %s called\n", method_name); \
38 if (*expected_method_list) \
39 { \
40 ok(!strcmp(*expected_method_list, method_name), "Expected %s to be called instead of %s\n", \
41 *expected_method_list, method_name); \
42 expected_method_list++; \
43 } \
44 } while(0)
46 static void test_streamonhglobal(void)
48 const char data[] = "Test String";
49 ULARGE_INTEGER ull;
50 IStream *pStream;
51 LARGE_INTEGER ll;
52 char buffer[128];
53 ULONG read;
54 STATSTG statstg;
55 HRESULT hr;
57 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
58 ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr);
60 ull.QuadPart = sizeof(data);
61 hr = IStream_SetSize(pStream, ull);
62 ok_ole_success(hr, "IStream_SetSize");
64 hr = IStream_Write(pStream, data, sizeof(data), NULL);
65 ok_ole_success(hr, "IStream_Write");
67 ll.QuadPart = 0;
68 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, NULL);
69 ok_ole_success(hr, "IStream_Seek");
71 /* should return S_OK, not S_FALSE */
72 hr = IStream_Read(pStream, buffer, sizeof(buffer), &read);
73 ok_ole_success(hr, "IStream_Read");
74 ok(read == sizeof(data), "IStream_Read returned read %d\n", read);
76 /* ignores HighPart */
77 ull.u.HighPart = -1;
78 ull.u.LowPart = 0;
79 hr = IStream_SetSize(pStream, ull);
80 ok_ole_success(hr, "IStream_SetSize");
82 /* IStream_Seek -- NULL position argument */
83 ll.u.HighPart = 0;
84 ll.u.LowPart = 0;
85 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, NULL);
86 ok_ole_success(hr, "IStream_Seek");
88 /* IStream_Seek -- valid position argument (seek from current position) */
89 ull.u.HighPart = 0xCAFECAFE;
90 ull.u.LowPart = 0xCAFECAFE;
91 ll.u.HighPart = 0;
92 ll.u.LowPart = 0;
93 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
94 ok_ole_success(hr, "IStream_Seek");
95 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
96 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
98 /* IStream_Seek -- invalid seek argument */
99 ull.u.HighPart = 0xCAFECAFE;
100 ull.u.LowPart = 0xCAFECAFE;
101 ll.u.HighPart = 0;
102 ll.u.LowPart = 123;
103 hr = IStream_Seek(pStream, ll, STREAM_SEEK_END+1, &ull);
104 ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
105 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
106 ok(ull.u.HighPart == 0, "should not have changed HighPart, got %d\n", ull.u.HighPart);
108 /* IStream_Seek -- valid position argument (seek to beginning) */
109 ull.u.HighPart = 0xCAFECAFE;
110 ull.u.LowPart = 0xCAFECAFE;
111 ll.u.HighPart = 0;
112 ll.u.LowPart = 0;
113 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
114 ok_ole_success(hr, "IStream_Seek");
115 ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart);
116 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
118 /* IStream_Seek -- valid position argument (seek to end) */
119 ull.u.HighPart = 0xCAFECAFE;
120 ull.u.LowPart = 0xCAFECAFE;
121 ll.u.HighPart = 0;
122 ll.u.LowPart = 0;
123 hr = IStream_Seek(pStream, ll, STREAM_SEEK_END, &ull);
124 ok_ole_success(hr, "IStream_Seek");
125 ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart);
126 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
128 /* IStream_Seek -- ignore HighPart in the move value (seek from current position) */
129 ll.u.HighPart = 0;
130 ll.u.LowPart = sizeof(data);
131 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
132 ok_ole_success(hr, "IStream_Seek");
134 ull.u.HighPart = 0xCAFECAFE;
135 ull.u.LowPart = 0xCAFECAFE;
136 ll.u.HighPart = -1;
137 ll.u.LowPart = 0;
138 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
139 ok_ole_success(hr, "IStream_Seek");
140 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
141 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
143 /* IStream_Seek -- ignore HighPart in the move value (seek to beginning) */
144 ll.u.HighPart = 0;
145 ll.u.LowPart = sizeof(data);
146 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
147 ok_ole_success(hr, "IStream_Seek");
149 ull.u.HighPart = 0xCAFECAFE;
150 ull.u.LowPart = 0xCAFECAFE;
151 ll.u.HighPart = -1;
152 ll.u.LowPart = 0;
153 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
154 ok_ole_success(hr, "IStream_Seek");
155 ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart);
156 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
158 /* IStream_Seek -- invalid LowPart value (seek before start of stream) */
159 ll.u.HighPart = 0;
160 ll.u.LowPart = sizeof(data);
161 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
162 ok_ole_success(hr, "IStream_Seek");
164 ull.u.HighPart = 0xCAFECAFE;
165 ull.u.LowPart = 0xCAFECAFE;
166 ll.u.HighPart = 0;
167 ll.u.LowPart = 0x80000000;
168 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
169 ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
170 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
171 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
173 /* IStream_Seek -- valid LowPart value (seek to start of stream) */
174 ll.u.HighPart = 0;
175 ll.u.LowPart = sizeof(data);
176 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
177 ok_ole_success(hr, "IStream_Seek");
179 ull.u.HighPart = 0xCAFECAFE;
180 ull.u.LowPart = 0xCAFECAFE;
181 ll.u.HighPart = 0;
182 ll.u.LowPart = -(DWORD)sizeof(data);
183 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
184 ok_ole_success(hr, "IStream_Seek");
185 ok(ull.u.LowPart == 0, "LowPart set to %d\n", ull.u.LowPart);
186 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
188 /* IStream_Seek -- invalid LowPart value (seek to start of stream-1) */
189 ll.u.HighPart = 0;
190 ll.u.LowPart = sizeof(data);
191 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
192 ok_ole_success(hr, "IStream_Seek");
194 ull.u.HighPart = 0xCAFECAFE;
195 ull.u.LowPart = 0xCAFECAFE;
196 ll.u.HighPart = 0;
197 ll.u.LowPart = -(DWORD)sizeof(data)-1;
198 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
199 ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
200 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
201 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
203 /* IStream_Seek -- valid LowPart value (seek forward to 0x80000000) */
204 ll.u.HighPart = 0;
205 ll.u.LowPart = sizeof(data);
206 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
207 ok_ole_success(hr, "IStream_Seek");
209 ull.u.HighPart = 0xCAFECAFE;
210 ull.u.LowPart = 0xCAFECAFE;
211 ll.u.HighPart = 0;
212 ll.u.LowPart = 0x80000000 - sizeof(data);
213 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
214 ok_ole_success(hr, "IStream_Seek");
215 ok(ull.u.LowPart == 0x80000000, "LowPart set to %d\n", ull.u.LowPart);
216 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
218 /* IStream_Seek -- invalid LowPart value (seek to beginning) */
219 ll.u.HighPart = 0;
220 ll.u.LowPart = sizeof(data);
221 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
222 ok_ole_success(hr, "IStream_Seek");
224 ull.u.HighPart = 0xCAFECAFE;
225 ull.u.LowPart = 0xCAFECAFE;
226 ll.u.HighPart = 0;
227 ll.u.LowPart = 0x80000000;
228 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
229 ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
230 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
231 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
233 /* IStream_Seek -- valid LowPart value (seek to beginning) */
234 ull.u.HighPart = 0xCAFECAFE;
235 ull.u.LowPart = 0xCAFECAFE;
236 ll.u.HighPart = 0;
237 ll.u.LowPart = 0x7FFFFFFF;
238 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
239 ok_ole_success(hr, "IStream_Seek");
240 ok(ull.u.LowPart == 0x7FFFFFFF, "should have set LowPart to 0x7FFFFFFF instead of %08x\n", ull.u.LowPart);
241 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
243 /* IStream_Seek -- valid LowPart value (seek from current position) */
244 ll.u.HighPart = 0;
245 ll.u.LowPart = 0;
246 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
247 ok_ole_success(hr, "IStream_Seek");
249 ull.u.HighPart = 0xCAFECAFE;
250 ull.u.LowPart = 0xCAFECAFE;
251 ll.u.HighPart = 0;
252 ll.u.LowPart = 0x7FFFFFFF;
253 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
254 ok_ole_success(hr, "IStream_Seek");
255 ok(ull.u.LowPart == 0x7FFFFFFF, "should have set LowPart to 0x7FFFFFFF instead of %08x\n", ull.u.LowPart);
256 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
258 /* IStream_Seek -- second seek allows you to go past 0x7FFFFFFF size */
259 ull.u.HighPart = 0xCAFECAFE;
260 ull.u.LowPart = 0xCAFECAFE;
261 ll.u.HighPart = 0;
262 ll.u.LowPart = 9;
263 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
264 ok_ole_success(hr, "IStream_Seek");
265 ok(ull.u.LowPart == 0x80000008, "should have set LowPart to 0x80000008 instead of %08x\n", ull.u.LowPart);
266 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
268 /* IStream_Seek -- seek wraps position/size on integer overflow, but not on win8 */
269 ull.u.HighPart = 0xCAFECAFE;
270 ull.u.LowPart = 0xCAFECAFE;
271 ll.u.HighPart = 0;
272 ll.u.LowPart = 0x7FFFFFFF;
273 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
274 ok(hr == S_OK || hr == STG_E_SEEKERROR /* win8 */, "IStream_Seek\n");
275 if (SUCCEEDED(hr))
276 ok(ull.u.LowPart == 0x00000007, "should have set LowPart to 0x00000007 instead of %08x\n", ull.u.LowPart);
277 else
278 ok(ull.u.LowPart == 0x80000008, "should have set LowPart to 0x80000008 instead of %08x\n", ull.u.LowPart);
279 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
281 hr = IStream_Commit(pStream, STGC_DEFAULT);
282 ok_ole_success(hr, "IStream_Commit");
284 hr = IStream_Revert(pStream);
285 ok_ole_success(hr, "IStream_Revert");
287 hr = IStream_LockRegion(pStream, ull, ull, LOCK_WRITE);
288 ok(hr == STG_E_INVALIDFUNCTION, "IStream_LockRegion should have returned STG_E_INVALIDFUNCTION instead of 0x%08x\n", hr);
290 hr = IStream_Stat(pStream, &statstg, STATFLAG_DEFAULT);
291 ok_ole_success(hr, "IStream_Stat");
292 ok(statstg.type == STGTY_STREAM, "statstg.type should have been STGTY_STREAM instead of %d\n", statstg.type);
294 /* test OOM condition */
295 ull.u.HighPart = -1;
296 ull.u.LowPart = -1;
297 hr = IStream_SetSize(pStream, ull);
298 ok(hr == E_OUTOFMEMORY || broken(hr == S_OK), /* win9x */
299 "IStream_SetSize with large size should have returned E_OUTOFMEMORY instead of 0x%08x\n", hr);
301 IStream_Release(pStream);
304 static HRESULT WINAPI TestStream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
306 if (IsEqualIID(riid, &IID_IUnknown) ||
307 IsEqualIID(riid, &IID_ISequentialStream) ||
308 IsEqualIID(riid, &IID_IStream))
310 *ppv = iface;
311 IStream_AddRef(iface);
312 return S_OK;
314 *ppv = NULL;
315 return E_NOINTERFACE;
318 static ULONG WINAPI TestStream_AddRef(IStream *iface)
320 return 2;
323 static ULONG WINAPI TestStream_Release(IStream *iface)
325 return 1;
328 static HRESULT WINAPI TestStream_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
330 CHECK_EXPECTED_METHOD("TestStream_Read");
331 return E_NOTIMPL;
334 static HRESULT WINAPI TestStream_Write(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
336 CHECK_EXPECTED_METHOD("TestStream_Write");
337 *pcbWritten = 5;
338 return S_OK;
341 static HRESULT WINAPI TestStream_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
343 CHECK_EXPECTED_METHOD("TestStream_Seek");
344 return E_NOTIMPL;
347 static HRESULT WINAPI TestStream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
349 CHECK_EXPECTED_METHOD("TestStream_SetSize");
350 return E_NOTIMPL;
353 static HRESULT WINAPI TestStream_CopyTo(IStream *iface, IStream *pStream, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
355 CHECK_EXPECTED_METHOD("TestStream_CopyTo");
356 return E_NOTIMPL;
359 static HRESULT WINAPI TestStream_Commit(IStream *iface, DWORD grfCommitFlags)
361 CHECK_EXPECTED_METHOD("TestStream_Commit");
362 return E_NOTIMPL;
365 static HRESULT WINAPI TestStream_Revert(IStream *iface)
367 CHECK_EXPECTED_METHOD("TestStream_Revert");
368 return E_NOTIMPL;
371 static HRESULT WINAPI TestStream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
373 CHECK_EXPECTED_METHOD("TestStream_LockRegion");
374 return E_NOTIMPL;
377 static HRESULT WINAPI TestStream_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
379 CHECK_EXPECTED_METHOD("TestStream_UnlockRegion");
380 return E_NOTIMPL;
383 static HRESULT WINAPI TestStream_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
385 CHECK_EXPECTED_METHOD("TestStream_Stat");
386 return E_NOTIMPL;
389 static HRESULT WINAPI TestStream_Clone(IStream *iface, IStream **pStream)
391 CHECK_EXPECTED_METHOD("TestStream_Clone");
392 return E_NOTIMPL;
395 static /*const*/ IStreamVtbl StreamVtbl =
397 TestStream_QueryInterface,
398 TestStream_AddRef,
399 TestStream_Release,
400 TestStream_Read,
401 TestStream_Write,
402 TestStream_Seek,
403 TestStream_SetSize,
404 TestStream_CopyTo,
405 TestStream_Commit,
406 TestStream_Revert,
407 TestStream_LockRegion,
408 TestStream_UnlockRegion,
409 TestStream_Stat,
410 TestStream_Clone
413 static IStream Test_Stream = { &StreamVtbl };
415 static void test_copyto(void)
417 IStream *pStream, *pStream2;
418 HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
419 static const char szHello[] = "Hello";
420 ULARGE_INTEGER cb;
421 static const char *methods_copyto[] =
423 "TestStream_Write",
424 NULL
426 ULONG written;
427 ULARGE_INTEGER ullRead;
428 ULARGE_INTEGER ullWritten;
429 ULARGE_INTEGER libNewPosition;
430 static const LARGE_INTEGER llZero;
431 char buffer[15];
433 ok_ole_success(hr, "CreateStreamOnHGlobal");
435 expected_method_list = methods_copyto;
437 hr = IStream_Write(pStream, szHello, sizeof(szHello), &written);
438 ok_ole_success(hr, "IStream_Write");
439 ok(written == sizeof(szHello), "only %d bytes written\n", written);
441 hr = IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
442 ok_ole_success(hr, "IStream_Seek");
444 cb.QuadPart = sizeof(szHello);
445 hr = IStream_CopyTo(pStream, &Test_Stream, cb, &ullRead, &ullWritten);
446 ok(ullWritten.QuadPart == 5, "ullWritten was %d instead\n", (ULONG)ullWritten.QuadPart);
447 ok(ullRead.QuadPart == sizeof(szHello), "only %d bytes read\n", (ULONG)ullRead.QuadPart);
448 ok_ole_success(hr, "IStream_CopyTo");
450 ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list);
452 hr = IStream_Clone(pStream, &pStream2);
453 ok_ole_success(hr, "IStream_Clone");
455 hr = IStream_Seek(pStream2, llZero, STREAM_SEEK_CUR, &libNewPosition);
456 ok_ole_success(hr, "IStream_Seek");
457 ok(libNewPosition.QuadPart == sizeof(szHello), "libNewPosition wasn't set correctly for the cloned stream\n");
459 hr = IStream_Seek(pStream2, llZero, STREAM_SEEK_SET, NULL);
460 ok_ole_success(hr, "IStream_Seek");
462 hr = IStream_Read(pStream2, buffer, sizeof(buffer), NULL);
463 ok_ole_success(hr, "IStream_Read");
464 ok(!strcmp(buffer, szHello), "read data \"%s\" didn't match originally written data\n", buffer);
466 IStream_Release(pStream2);
467 IStream_Release(pStream);
470 static void test_freed_hglobal(void)
472 static const char teststring[] = "this is a test string";
473 HRESULT hr;
474 IStream *pStream;
475 HGLOBAL hglobal;
476 char *p;
477 char buffer[sizeof(teststring) + 8];
478 ULARGE_INTEGER ull;
479 ULONG read, written;
481 hglobal = GlobalAlloc(GMEM_DDESHARE|GMEM_NODISCARD|GMEM_MOVEABLE, strlen(teststring) + 1);
482 ok(hglobal != NULL, "GlobalAlloc failed with error %d\n", GetLastError());
483 p = GlobalLock(hglobal);
484 strcpy(p, teststring);
485 GlobalUnlock(hglobal);
487 hr = CreateStreamOnHGlobal(hglobal, FALSE, &pStream);
488 ok_ole_success(hr, "CreateStreamOnHGlobal");
490 hr = IStream_Read(pStream, buffer, sizeof(buffer), &read);
491 ok_ole_success(hr, "IStream_Read");
492 ok(!strcmp(buffer, teststring), "buffer data %s differs\n", buffer);
493 ok(read == sizeof(teststring) ||
494 broken(read == ((sizeof(teststring) + 3) & ~3)), /* win9x rounds the size */
495 "read should be sizeof(teststring) instead of %d\n", read);
497 GlobalFree(hglobal);
499 memset(buffer, 0, sizeof(buffer));
500 read = -1;
501 hr = IStream_Read(pStream, buffer, sizeof(buffer), &read);
502 ok_ole_success(hr, "IStream_Read");
503 ok(buffer[0] == 0, "buffer data should be untouched\n");
504 ok(read == 0, "read should be 0 instead of %d\n", read);
506 ull.QuadPart = sizeof(buffer);
507 hr = IStream_SetSize(pStream, ull);
508 ok(hr == E_OUTOFMEMORY, "IStream_SetSize with invalid HGLOBAL should return E_OUTOFMEMORY instead of 0x%08x\n", hr);
510 hr = IStream_Write(pStream, buffer, sizeof(buffer), &written);
511 ok(hr == E_OUTOFMEMORY, "IStream_Write with invalid HGLOBAL should return E_OUTOFMEMORY instead of 0x%08x\n", hr);
512 ok(written == 0, "written should be 0 instead of %d\n", written);
514 IStream_Release(pStream);
517 START_TEST(hglobalstream)
519 test_streamonhglobal();
520 test_copyto();
521 test_freed_hglobal();