dmscript: Merge the IClassFactory implementations.
[wine/testsucceed.git] / dlls / ole32 / tests / hglobalstream.c
blob769d5a1a1ed3683421d0d6604dbd17665afa0eaf
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(IStream *pStream)
48 const char data[] = "Test String";
49 ULARGE_INTEGER ull;
50 LARGE_INTEGER ll;
51 char buffer[128];
52 ULONG read;
53 STATSTG statstg;
54 HRESULT hr;
56 ull.QuadPart = sizeof(data);
57 hr = IStream_SetSize(pStream, ull);
58 ok_ole_success(hr, "IStream_SetSize");
60 hr = IStream_Write(pStream, data, sizeof(data), NULL);
61 ok_ole_success(hr, "IStream_Write");
63 ll.QuadPart = 0;
64 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, NULL);
65 ok_ole_success(hr, "IStream_Seek");
67 /* should return S_OK, not S_FALSE */
68 hr = IStream_Read(pStream, buffer, sizeof(buffer), &read);
69 ok_ole_success(hr, "IStream_Read");
70 ok(read == sizeof(data), "IStream_Read returned read %d\n", read);
72 /* ignores HighPart */
73 ull.u.HighPart = -1;
74 ull.u.LowPart = 0;
75 hr = IStream_SetSize(pStream, ull);
76 ok_ole_success(hr, "IStream_SetSize");
78 /* IStream_Seek -- NULL position argument */
79 ll.u.HighPart = 0;
80 ll.u.LowPart = 0;
81 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, NULL);
82 ok_ole_success(hr, "IStream_Seek");
84 /* IStream_Seek -- valid position argument (seek from current position) */
85 ull.u.HighPart = 0xCAFECAFE;
86 ull.u.LowPart = 0xCAFECAFE;
87 ll.u.HighPart = 0;
88 ll.u.LowPart = 0;
89 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
90 ok_ole_success(hr, "IStream_Seek");
91 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
92 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
94 /* IStream_Seek -- invalid seek argument */
95 ull.u.HighPart = 0xCAFECAFE;
96 ull.u.LowPart = 0xCAFECAFE;
97 ll.u.HighPart = 0;
98 ll.u.LowPart = 123;
99 hr = IStream_Seek(pStream, ll, STREAM_SEEK_END+1, &ull);
100 ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
101 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
102 ok(ull.u.HighPart == 0, "should not have changed HighPart, got %d\n", ull.u.HighPart);
104 /* IStream_Seek -- valid position argument (seek to beginning) */
105 ull.u.HighPart = 0xCAFECAFE;
106 ull.u.LowPart = 0xCAFECAFE;
107 ll.u.HighPart = 0;
108 ll.u.LowPart = 0;
109 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
110 ok_ole_success(hr, "IStream_Seek");
111 ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart);
112 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
114 /* IStream_Seek -- valid position argument (seek to end) */
115 ull.u.HighPart = 0xCAFECAFE;
116 ull.u.LowPart = 0xCAFECAFE;
117 ll.u.HighPart = 0;
118 ll.u.LowPart = 0;
119 hr = IStream_Seek(pStream, ll, STREAM_SEEK_END, &ull);
120 ok_ole_success(hr, "IStream_Seek");
121 ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart);
122 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
124 /* IStream_Seek -- ignore HighPart in the move value (seek from current position) */
125 ll.u.HighPart = 0;
126 ll.u.LowPart = sizeof(data);
127 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
128 ok_ole_success(hr, "IStream_Seek");
130 ull.u.HighPart = 0xCAFECAFE;
131 ull.u.LowPart = 0xCAFECAFE;
132 ll.u.HighPart = -1;
133 ll.u.LowPart = 0;
134 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
135 ok_ole_success(hr, "IStream_Seek");
136 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
137 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
139 /* IStream_Seek -- ignore HighPart in the move value (seek to beginning) */
140 ll.u.HighPart = 0;
141 ll.u.LowPart = sizeof(data);
142 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
143 ok_ole_success(hr, "IStream_Seek");
145 ull.u.HighPart = 0xCAFECAFE;
146 ull.u.LowPart = 0xCAFECAFE;
147 ll.u.HighPart = -1;
148 ll.u.LowPart = 0;
149 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
150 ok_ole_success(hr, "IStream_Seek");
151 ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart);
152 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
154 /* IStream_Seek -- invalid LowPart value (seek before start of stream) */
155 ll.u.HighPart = 0;
156 ll.u.LowPart = sizeof(data);
157 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
158 ok_ole_success(hr, "IStream_Seek");
160 ull.u.HighPart = 0xCAFECAFE;
161 ull.u.LowPart = 0xCAFECAFE;
162 ll.u.HighPart = 0;
163 ll.u.LowPart = 0x80000000;
164 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
165 ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
166 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
167 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
169 /* IStream_Seek -- valid LowPart value (seek to start of stream) */
170 ll.u.HighPart = 0;
171 ll.u.LowPart = sizeof(data);
172 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
173 ok_ole_success(hr, "IStream_Seek");
175 ull.u.HighPart = 0xCAFECAFE;
176 ull.u.LowPart = 0xCAFECAFE;
177 ll.u.HighPart = 0;
178 ll.u.LowPart = -(DWORD)sizeof(data);
179 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
180 ok_ole_success(hr, "IStream_Seek");
181 ok(ull.u.LowPart == 0, "LowPart set to %d\n", ull.u.LowPart);
182 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
184 /* IStream_Seek -- invalid LowPart value (seek to start of stream-1) */
185 ll.u.HighPart = 0;
186 ll.u.LowPart = sizeof(data);
187 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
188 ok_ole_success(hr, "IStream_Seek");
190 ull.u.HighPart = 0xCAFECAFE;
191 ull.u.LowPart = 0xCAFECAFE;
192 ll.u.HighPart = 0;
193 ll.u.LowPart = -(DWORD)sizeof(data)-1;
194 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
195 ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
196 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
197 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
199 /* IStream_Seek -- valid LowPart value (seek forward to 0x80000000) */
200 ll.u.HighPart = 0;
201 ll.u.LowPart = sizeof(data);
202 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
203 ok_ole_success(hr, "IStream_Seek");
205 ull.u.HighPart = 0xCAFECAFE;
206 ull.u.LowPart = 0xCAFECAFE;
207 ll.u.HighPart = 0;
208 ll.u.LowPart = 0x80000000 - sizeof(data);
209 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
210 ok_ole_success(hr, "IStream_Seek");
211 ok(ull.u.LowPart == 0x80000000, "LowPart set to %d\n", ull.u.LowPart);
212 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
214 /* IStream_Seek -- invalid LowPart value (seek to beginning) */
215 ll.u.HighPart = 0;
216 ll.u.LowPart = sizeof(data);
217 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
218 ok_ole_success(hr, "IStream_Seek");
220 ull.u.HighPart = 0xCAFECAFE;
221 ull.u.LowPart = 0xCAFECAFE;
222 ll.u.HighPart = 0;
223 ll.u.LowPart = 0x80000000;
224 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
225 ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
226 ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
227 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
229 /* IStream_Seek -- valid LowPart value (seek to beginning) */
230 ull.u.HighPart = 0xCAFECAFE;
231 ull.u.LowPart = 0xCAFECAFE;
232 ll.u.HighPart = 0;
233 ll.u.LowPart = 0x7FFFFFFF;
234 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
235 ok_ole_success(hr, "IStream_Seek");
236 ok(ull.u.LowPart == 0x7FFFFFFF, "should have set LowPart to 0x7FFFFFFF instead of %08x\n", ull.u.LowPart);
237 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
239 /* IStream_Seek -- valid LowPart value (seek from current position) */
240 ll.u.HighPart = 0;
241 ll.u.LowPart = 0;
242 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
243 ok_ole_success(hr, "IStream_Seek");
245 ull.u.HighPart = 0xCAFECAFE;
246 ull.u.LowPart = 0xCAFECAFE;
247 ll.u.HighPart = 0;
248 ll.u.LowPart = 0x7FFFFFFF;
249 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
250 ok_ole_success(hr, "IStream_Seek");
251 ok(ull.u.LowPart == 0x7FFFFFFF, "should have set LowPart to 0x7FFFFFFF instead of %08x\n", ull.u.LowPart);
252 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
254 /* IStream_Seek -- second seek allows you to go past 0x7FFFFFFF size */
255 ull.u.HighPart = 0xCAFECAFE;
256 ull.u.LowPart = 0xCAFECAFE;
257 ll.u.HighPart = 0;
258 ll.u.LowPart = 9;
259 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
260 ok_ole_success(hr, "IStream_Seek");
261 ok(ull.u.LowPart == 0x80000008, "should have set LowPart to 0x80000008 instead of %08x\n", ull.u.LowPart);
262 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
264 /* IStream_Seek -- seek wraps position/size on integer overflow */
265 ull.u.HighPart = 0xCAFECAFE;
266 ull.u.LowPart = 0xCAFECAFE;
267 ll.u.HighPart = 0;
268 ll.u.LowPart = 0x7FFFFFFF;
269 hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
270 ok_ole_success(hr, "IStream_Seek");
271 ok(ull.u.LowPart == 0x00000007, "should have set LowPart to 0x00000007 instead of %08x\n", ull.u.LowPart);
272 ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
274 hr = IStream_Commit(pStream, STGC_DEFAULT);
275 ok_ole_success(hr, "IStream_Commit");
277 hr = IStream_Revert(pStream);
278 ok_ole_success(hr, "IStream_Revert");
280 hr = IStream_LockRegion(pStream, ull, ull, LOCK_WRITE);
281 ok(hr == STG_E_INVALIDFUNCTION, "IStream_LockRegion should have returned STG_E_INVALIDFUNCTION instead of 0x%08x\n", hr);
283 hr = IStream_Stat(pStream, &statstg, STATFLAG_DEFAULT);
284 ok_ole_success(hr, "IStream_Stat");
285 ok(statstg.type == STGTY_STREAM, "statstg.type should have been STGTY_STREAM instead of %d\n", statstg.type);
287 /* test OOM condition */
288 ull.u.HighPart = -1;
289 ull.u.LowPart = -1;
290 hr = IStream_SetSize(pStream, ull);
291 ok(hr == E_OUTOFMEMORY || broken(hr == S_OK), /* win9x */
292 "IStream_SetSize with large size should have returned E_OUTOFMEMORY instead of 0x%08x\n", hr);
295 static HRESULT WINAPI TestStream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
297 if (IsEqualIID(riid, &IID_IUnknown) ||
298 IsEqualIID(riid, &IID_ISequentialStream) ||
299 IsEqualIID(riid, &IID_IStream))
301 *ppv = iface;
302 IUnknown_AddRef(iface);
303 return S_OK;
305 *ppv = NULL;
306 return E_NOINTERFACE;
309 static ULONG WINAPI TestStream_AddRef(IStream *iface)
311 return 2;
314 static ULONG WINAPI TestStream_Release(IStream *iface)
316 return 1;
319 static HRESULT WINAPI TestStream_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
321 CHECK_EXPECTED_METHOD("TestStream_Read");
322 return E_NOTIMPL;
325 static HRESULT WINAPI TestStream_Write(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
327 CHECK_EXPECTED_METHOD("TestStream_Write");
328 *pcbWritten = 5;
329 return S_OK;
332 static HRESULT WINAPI TestStream_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
334 CHECK_EXPECTED_METHOD("TestStream_Seek");
335 return E_NOTIMPL;
338 static HRESULT WINAPI TestStream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
340 CHECK_EXPECTED_METHOD("TestStream_SetSize");
341 return E_NOTIMPL;
344 static HRESULT WINAPI TestStream_CopyTo(IStream *iface, IStream *pStream, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
346 CHECK_EXPECTED_METHOD("TestStream_CopyTo");
347 return E_NOTIMPL;
350 static HRESULT WINAPI TestStream_Commit(IStream *iface, DWORD grfCommitFlags)
352 CHECK_EXPECTED_METHOD("TestStream_Commit");
353 return E_NOTIMPL;
356 static HRESULT WINAPI TestStream_Revert(IStream *iface)
358 CHECK_EXPECTED_METHOD("TestStream_Revert");
359 return E_NOTIMPL;
362 static HRESULT WINAPI TestStream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
364 CHECK_EXPECTED_METHOD("TestStream_LockRegion");
365 return E_NOTIMPL;
368 static HRESULT WINAPI TestStream_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
370 CHECK_EXPECTED_METHOD("TestStream_UnlockRegion");
371 return E_NOTIMPL;
374 static HRESULT WINAPI TestStream_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
376 CHECK_EXPECTED_METHOD("TestStream_Stat");
377 return E_NOTIMPL;
380 static HRESULT WINAPI TestStream_Clone(IStream *iface, IStream **pStream)
382 CHECK_EXPECTED_METHOD("TestStream_Clone");
383 return E_NOTIMPL;
386 static /*const*/ IStreamVtbl StreamVtbl =
388 TestStream_QueryInterface,
389 TestStream_AddRef,
390 TestStream_Release,
391 TestStream_Read,
392 TestStream_Write,
393 TestStream_Seek,
394 TestStream_SetSize,
395 TestStream_CopyTo,
396 TestStream_Commit,
397 TestStream_Revert,
398 TestStream_LockRegion,
399 TestStream_UnlockRegion,
400 TestStream_Stat,
401 TestStream_Clone
404 static IStream Test_Stream = { &StreamVtbl };
406 static void test_copyto(void)
408 IStream *pStream, *pStream2;
409 HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
410 static const char szHello[] = "Hello";
411 ULARGE_INTEGER cb;
412 static const char *methods_copyto[] =
414 "TestStream_Write",
415 NULL
417 ULONG written;
418 ULARGE_INTEGER ullRead;
419 ULARGE_INTEGER ullWritten;
420 ULARGE_INTEGER libNewPosition;
421 static const LARGE_INTEGER llZero;
422 char buffer[15];
424 ok_ole_success(hr, "CreateStreamOnHGlobal");
426 expected_method_list = methods_copyto;
428 hr = IStream_Write(pStream, szHello, sizeof(szHello), &written);
429 ok_ole_success(hr, "IStream_Write");
430 ok(written == sizeof(szHello), "only %d bytes written\n", written);
432 hr = IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
433 ok_ole_success(hr, "IStream_Seek");
435 cb.QuadPart = sizeof(szHello);
436 hr = IStream_CopyTo(pStream, &Test_Stream, cb, &ullRead, &ullWritten);
437 ok(ullWritten.QuadPart == 5, "ullWritten was %d instead\n", (ULONG)ullWritten.QuadPart);
438 ok(ullRead.QuadPart == sizeof(szHello), "only %d bytes read\n", (ULONG)ullRead.QuadPart);
439 ok_ole_success(hr, "IStream_CopyTo");
441 ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list);
443 hr = IStream_Clone(pStream, &pStream2);
444 ok_ole_success(hr, "IStream_Clone");
446 hr = IStream_Seek(pStream2, llZero, STREAM_SEEK_CUR, &libNewPosition);
447 ok_ole_success(hr, "IStream_Seek");
448 ok(libNewPosition.QuadPart == sizeof(szHello), "libNewPosition wasn't set correctly for the cloned stream\n");
450 hr = IStream_Seek(pStream2, llZero, STREAM_SEEK_SET, NULL);
451 ok_ole_success(hr, "IStream_Seek");
453 hr = IStream_Read(pStream2, buffer, sizeof(buffer), NULL);
454 ok_ole_success(hr, "IStream_Read");
455 ok(!strcmp(buffer, szHello), "read data \"%s\" didn't match originally written data\n", buffer);
457 IStream_Release(pStream2);
458 IStream_Release(pStream);
461 static void test_freed_hglobal(void)
463 static const char teststring[] = "this is a test string";
464 HRESULT hr;
465 IStream *pStream;
466 HGLOBAL hglobal;
467 char *p;
468 char buffer[sizeof(teststring) + 8];
469 ULARGE_INTEGER ull;
470 ULONG read, written;
472 hglobal = GlobalAlloc(GMEM_DDESHARE|GMEM_NODISCARD|GMEM_MOVEABLE, strlen(teststring) + 1);
473 ok(hglobal != NULL, "GlobalAlloc failed with error %d\n", GetLastError());
474 p = GlobalLock(hglobal);
475 strcpy(p, teststring);
476 GlobalUnlock(hglobal);
478 hr = CreateStreamOnHGlobal(hglobal, FALSE, &pStream);
479 ok_ole_success(hr, "CreateStreamOnHGlobal");
481 hr = IStream_Read(pStream, buffer, sizeof(buffer), &read);
482 ok_ole_success(hr, "IStream_Read");
483 ok(!strcmp(buffer, teststring), "buffer data %s differs\n", buffer);
484 ok(read == sizeof(teststring) ||
485 broken(read == ((sizeof(teststring) + 3) & ~3)), /* win9x rounds the size */
486 "read should be sizeof(teststring) instead of %d\n", read);
488 GlobalFree(hglobal);
490 memset(buffer, 0, sizeof(buffer));
491 read = -1;
492 hr = IStream_Read(pStream, buffer, sizeof(buffer), &read);
493 ok_ole_success(hr, "IStream_Read");
494 ok(buffer[0] == 0, "buffer data should be untouched\n");
495 ok(read == 0, "read should be 0 instead of %d\n", read);
497 ull.QuadPart = sizeof(buffer);
498 hr = IStream_SetSize(pStream, ull);
499 ok(hr == E_OUTOFMEMORY, "IStream_SetSize with invalid HGLOBAL should return E_OUTOFMEMORY instead of 0x%08x\n", hr);
501 hr = IStream_Write(pStream, buffer, sizeof(buffer), &written);
502 ok(hr == E_OUTOFMEMORY, "IStream_Write with invalid HGLOBAL should return E_OUTOFMEMORY instead of 0x%08x\n", hr);
503 ok(written == 0, "written should be 0 instead of %d\n", written);
505 IStream_Release(pStream);
508 START_TEST(hglobalstream)
510 HRESULT hr;
511 IStream *pStream;
513 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
514 ok_ole_success(hr, "CreateStreamOnHGlobal");
516 test_streamonhglobal(pStream);
517 IStream_Release(pStream);
518 test_copyto();
519 test_freed_hglobal();