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
29 #include "wine/test.h"
31 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08lx\n", hr)
33 static void test_streamonhglobal(IStream *pStream)
35 const char data[] = "Test String";
43 ull.QuadPart = sizeof(data);
44 hr = IStream_SetSize(pStream, ull);
45 ok_ole_success(hr, "IStream_SetSize");
47 hr = IStream_Write(pStream, data, sizeof(data), NULL);
48 ok_ole_success(hr, "IStream_Write");
51 hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, NULL);
52 ok_ole_success(hr, "IStream_Seek");
54 /* should return S_OK, not S_FALSE */
55 hr = IStream_Read(pStream, buffer, sizeof(buffer), &read);
56 ok_ole_success(hr, "IStream_Read");
57 ok(read == sizeof(data), "IStream_Read returned read %ld instead of %d\n", read, sizeof(data));
59 /* ignores HighPart */
62 hr = IStream_SetSize(pStream, ull);
63 ok_ole_success(hr, "IStream_SetSize");
65 hr = IStream_Commit(pStream, STGC_DEFAULT);
66 ok_ole_success(hr, "IStream_Commit");
68 hr = IStream_Revert(pStream);
69 ok_ole_success(hr, "IStream_Revert");
71 hr = IStream_LockRegion(pStream, ull, ull, LOCK_WRITE);
72 ok(hr == STG_E_INVALIDFUNCTION, "IStream_LockRegion should have returned STG_E_INVALIDFUNCTION instead of 0x%08lx\n", hr);
74 hr = IStream_Stat(pStream, &statstg, STATFLAG_DEFAULT);
75 ok_ole_success(hr, "IStream_Stat");
76 ok(statstg.type == STGTY_STREAM, "statstg.type should have been STGTY_STREAM instead of %ld\n", statstg.type);
78 /* test OOM condition */
81 hr = IStream_SetSize(pStream, ull);
83 ok(hr == E_OUTOFMEMORY, "IStream_SetSize with large size should have returned E_OUTOFMEMORY instead of 0x%08lx\n", hr);
87 START_TEST(hglobalstream)
92 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
93 ok_ole_success(hr, "CreateStreamOnHGlobal");
95 test_streamonhglobal(pStream);