2003-05-16 01:58:48 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for DPA functions
|
|
|
|
*
|
|
|
|
* Copyright 2003 Uwe Bonnes
|
2005-07-03 14:02:09 +02:00
|
|
|
* Copyright 2005 Felix Nawothnig
|
2003-05-16 01:58:48 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-05-16 01:58:48 +02:00
|
|
|
*/
|
|
|
|
|
2005-07-03 14:02:09 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
2003-05-16 01:58:48 +02:00
|
|
|
#include "winbase.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winuser.h"
|
2003-05-16 01:58:48 +02:00
|
|
|
#include "commctrl.h"
|
2005-07-03 14:02:09 +02:00
|
|
|
#include "objidl.h"
|
2003-05-16 01:58:48 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
2018-01-29 12:20:42 +01:00
|
|
|
#include "v6util.h"
|
2003-05-16 01:58:48 +02:00
|
|
|
|
2022-02-24 11:26:53 +01:00
|
|
|
#define expect(expected,got) expect_(__LINE__, expected, got)
|
|
|
|
static inline void expect_(unsigned line, DWORD expected, DWORD got)
|
|
|
|
{
|
2022-02-28 08:25:25 +01:00
|
|
|
ok_(__FILE__, line)(expected == got, "Expected %ld, got %ld\n", expected, got);
|
2022-02-24 11:26:53 +01:00
|
|
|
}
|
2009-09-10 20:17:09 +02:00
|
|
|
|
2009-09-12 01:17:54 +02:00
|
|
|
typedef struct _STREAMDATA
|
|
|
|
{
|
|
|
|
DWORD dwSize;
|
|
|
|
DWORD dwData2;
|
|
|
|
DWORD dwItems;
|
|
|
|
} STREAMDATA, *PSTREAMDATA;
|
|
|
|
|
2013-09-28 17:18:03 +02:00
|
|
|
static HDPA (WINAPI *pDPA_Clone)(const HDPA,HDPA);
|
2005-07-03 14:02:09 +02:00
|
|
|
static HDPA (WINAPI *pDPA_Create)(INT);
|
|
|
|
static HDPA (WINAPI *pDPA_CreateEx)(INT,HANDLE);
|
2013-09-28 17:18:03 +02:00
|
|
|
static PVOID (WINAPI *pDPA_DeleteAllPtrs)(HDPA);
|
|
|
|
static PVOID (WINAPI *pDPA_DeletePtr)(HDPA,INT);
|
|
|
|
static BOOL (WINAPI *pDPA_Destroy)(HDPA);
|
2005-07-03 14:02:09 +02:00
|
|
|
static VOID (WINAPI *pDPA_DestroyCallback)(HDPA,PFNDPAENUMCALLBACK,PVOID);
|
|
|
|
static VOID (WINAPI *pDPA_EnumCallback)(HDPA,PFNDPAENUMCALLBACK,PVOID);
|
2021-03-08 15:44:37 +01:00
|
|
|
static PVOID (WINAPI *pDPA_GetPtr)(HDPA,INT_PTR);
|
2013-09-28 17:18:03 +02:00
|
|
|
static INT (WINAPI *pDPA_GetPtrIndex)(HDPA,PVOID);
|
2005-07-03 14:02:09 +02:00
|
|
|
static BOOL (WINAPI *pDPA_Grow)(HDPA,INT);
|
2013-09-28 17:18:03 +02:00
|
|
|
static INT (WINAPI *pDPA_InsertPtr)(HDPA,INT,PVOID);
|
2009-09-12 01:17:54 +02:00
|
|
|
static HRESULT (WINAPI *pDPA_LoadStream)(HDPA*,PFNDPASTREAM,IStream*,LPVOID);
|
2013-09-28 17:18:03 +02:00
|
|
|
static BOOL (WINAPI *pDPA_Merge)(HDPA,HDPA,DWORD,PFNDPACOMPARE,PFNDPAMERGE,LPARAM);
|
2009-09-12 01:17:54 +02:00
|
|
|
static HRESULT (WINAPI *pDPA_SaveStream)(HDPA,PFNDPASTREAM,IStream*,LPVOID);
|
2005-07-03 14:02:09 +02:00
|
|
|
static INT (WINAPI *pDPA_Search)(HDPA,PVOID,INT,PFNDPACOMPARE,LPARAM,UINT);
|
2013-09-28 17:18:03 +02:00
|
|
|
static BOOL (WINAPI *pDPA_SetPtr)(HDPA,INT,PVOID);
|
|
|
|
static BOOL (WINAPI *pDPA_Sort)(HDPA,PFNDPACOMPARE,LPARAM);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
static void init_functions(void)
|
2003-05-16 01:58:48 +02:00
|
|
|
{
|
2018-01-24 13:47:09 +01:00
|
|
|
HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
|
2005-07-03 14:02:09 +02:00
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
#define X2(f, ord) p##f = (void*)GetProcAddress(hComCtl32, (const char *)ord);
|
|
|
|
/* 4.00+ */
|
|
|
|
X2(DPA_Clone, 331);
|
|
|
|
X2(DPA_Create, 328);
|
|
|
|
X2(DPA_CreateEx, 340);
|
|
|
|
X2(DPA_DeleteAllPtrs, 337);
|
|
|
|
X2(DPA_DeletePtr, 336);
|
|
|
|
X2(DPA_Destroy, 329);
|
|
|
|
X2(DPA_GetPtr, 332);
|
|
|
|
X2(DPA_GetPtrIndex, 333);
|
|
|
|
X2(DPA_Grow, 330);
|
|
|
|
X2(DPA_InsertPtr, 334);
|
|
|
|
X2(DPA_Search, 339);
|
|
|
|
X2(DPA_SetPtr, 335);
|
|
|
|
X2(DPA_Sort, 338);
|
|
|
|
|
|
|
|
/* 4.71+ */
|
|
|
|
X2(DPA_DestroyCallback, 386);
|
|
|
|
X2(DPA_EnumCallback, 385);
|
|
|
|
X2(DPA_LoadStream, 9);
|
|
|
|
X2(DPA_Merge, 11);
|
|
|
|
X2(DPA_SaveStream, 10);
|
|
|
|
#undef X2
|
2003-05-16 01:58:48 +02:00
|
|
|
}
|
|
|
|
|
2005-07-03 14:02:09 +02:00
|
|
|
/* Callbacks */
|
|
|
|
static INT CALLBACK CB_CmpLT(PVOID p1, PVOID p2, LPARAM lp)
|
|
|
|
{
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(lp == 0x1abe11ed, "lp=%Id\n", lp);
|
2005-07-03 14:02:09 +02:00
|
|
|
return p1 < p2 ? -1 : p1 > p2 ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT CALLBACK CB_CmpGT(PVOID p1, PVOID p2, LPARAM lp)
|
|
|
|
{
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(lp == 0x1abe11ed, "lp=%Id\n", lp);
|
2005-07-03 14:02:09 +02:00
|
|
|
return p1 > p2 ? -1 : p1 < p2 ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2009-09-10 20:17:09 +02:00
|
|
|
/* merge callback messages counter
|
|
|
|
DPAMM_MERGE 1
|
|
|
|
DPAMM_DELETE 2
|
|
|
|
DPAMM_INSERT 3 */
|
|
|
|
static INT nMessages[4];
|
|
|
|
|
2005-07-03 14:02:09 +02:00
|
|
|
static PVOID CALLBACK CB_MergeInsertSrc(UINT op, PVOID p1, PVOID p2, LPARAM lp)
|
|
|
|
{
|
2009-09-10 20:17:09 +02:00
|
|
|
nMessages[op]++;
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(lp == 0x1abe11ed, "lp=%Id\n", lp);
|
2005-07-03 14:02:09 +02:00
|
|
|
return p1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PVOID CALLBACK CB_MergeDeleteOddSrc(UINT op, PVOID p1, PVOID p2, LPARAM lp)
|
2003-05-16 01:58:48 +02:00
|
|
|
{
|
2009-09-10 20:17:09 +02:00
|
|
|
nMessages[op]++;
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(lp == 0x1abe11ed, "lp=%Id\n", lp);
|
2005-07-03 14:02:09 +02:00
|
|
|
return ((PCHAR)p2)+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT nEnum;
|
|
|
|
|
|
|
|
static INT CALLBACK CB_EnumFirstThree(PVOID pItem, PVOID lp)
|
|
|
|
{
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
i = pDPA_GetPtrIndex(lp, pItem);
|
|
|
|
ok(i == nEnum, "i=%d nEnum=%d\n", i, nEnum);
|
|
|
|
nEnum++;
|
|
|
|
pDPA_SetPtr(lp, i, (PVOID)7);
|
|
|
|
return pItem != (PVOID)3;
|
|
|
|
}
|
|
|
|
|
2009-09-10 21:45:56 +02:00
|
|
|
static HRESULT CALLBACK CB_Save(DPASTREAMINFO *pInfo, IStream *pStm, LPVOID lp)
|
2005-07-03 14:02:09 +02:00
|
|
|
{
|
|
|
|
HRESULT hRes;
|
2009-09-14 09:16:06 +02:00
|
|
|
|
2009-09-10 21:45:56 +02:00
|
|
|
ok(lp == (LPVOID)0xdeadbeef, "lp=%p\n", lp);
|
2005-07-03 14:02:09 +02:00
|
|
|
hRes = IStream_Write(pStm, &pInfo->iPos, sizeof(INT), NULL);
|
2009-09-14 09:16:06 +02:00
|
|
|
expect(S_OK, hRes);
|
2009-09-10 21:45:56 +02:00
|
|
|
hRes = IStream_Write(pStm, &pInfo->pvItem, sizeof(PVOID), NULL);
|
2009-09-14 09:16:06 +02:00
|
|
|
expect(S_OK, hRes);
|
2005-07-03 14:02:09 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-10 21:45:56 +02:00
|
|
|
static HRESULT CALLBACK CB_Load(DPASTREAMINFO *pInfo, IStream *pStm, LPVOID lp)
|
2005-07-03 14:02:09 +02:00
|
|
|
{
|
|
|
|
HRESULT hRes;
|
|
|
|
INT iOldPos;
|
|
|
|
|
|
|
|
iOldPos = pInfo->iPos;
|
2009-09-10 21:45:56 +02:00
|
|
|
ok(lp == (LPVOID)0xdeadbeef, "lp=%p\n", lp);
|
2005-07-03 14:02:09 +02:00
|
|
|
hRes = IStream_Read(pStm, &pInfo->iPos, sizeof(INT), NULL);
|
2009-09-14 09:16:06 +02:00
|
|
|
expect(S_OK, hRes);
|
2005-07-03 14:02:09 +02:00
|
|
|
ok(pInfo->iPos == iOldPos, "iPos=%d iOldPos=%d\n", pInfo->iPos, iOldPos);
|
2009-09-10 21:45:56 +02:00
|
|
|
hRes = IStream_Read(pStm, &pInfo->pvItem, sizeof(PVOID), NULL);
|
2009-09-14 09:16:06 +02:00
|
|
|
expect(S_OK, hRes);
|
2005-07-03 14:02:09 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CheckDPA(HDPA dpa, DWORD dwIn, PDWORD pdwOut)
|
|
|
|
{
|
|
|
|
DWORD dwOut = 0;
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
for(i = 0; i < 8;)
|
|
|
|
{
|
|
|
|
ULONG_PTR ulItem = (ULONG_PTR)pDPA_GetPtr(dpa, i++);
|
|
|
|
if(!ulItem) break;
|
|
|
|
dwOut = dwOut << 4 | (ulItem & 0xf);
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdwOut = dwOut;
|
|
|
|
|
|
|
|
if(dwOut != dwIn)
|
|
|
|
{
|
|
|
|
pDPA_DeleteAllPtrs(dpa);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2009-01-03 20:13:20 +01:00
|
|
|
pDPA_InsertPtr(dpa, 0, (PVOID)(ULONG_PTR)(dwIn & 0xf));
|
2005-07-03 14:02:09 +02:00
|
|
|
dwIn >>= 4;
|
|
|
|
}
|
|
|
|
while(dwIn);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_dpa(void)
|
|
|
|
{
|
|
|
|
SYSTEM_INFO si;
|
|
|
|
HANDLE hHeap;
|
|
|
|
HDPA dpa, dpa2, dpa3;
|
|
|
|
INT ret, i;
|
|
|
|
PVOID p;
|
|
|
|
DWORD dw, dw2, dw3;
|
2006-11-23 21:37:08 +01:00
|
|
|
BOOL rc;
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
GetSystemInfo(&si);
|
|
|
|
hHeap = HeapCreate(0, 1, 2);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(hHeap != NULL, "error=%ld\n", GetLastError());
|
2005-07-03 14:02:09 +02:00
|
|
|
dpa3 = pDPA_CreateEx(0, hHeap);
|
|
|
|
ok(dpa3 != NULL, "\n");
|
|
|
|
ret = pDPA_Grow(dpa3, si.dwPageSize + 1);
|
2010-01-29 13:18:56 +01:00
|
|
|
ok(!ret && GetLastError() == ERROR_NOT_ENOUGH_MEMORY,
|
2022-02-28 08:25:25 +01:00
|
|
|
"ret=%d error=%ld\n", ret, GetLastError());
|
2010-01-29 13:18:56 +01:00
|
|
|
|
2005-07-03 14:02:09 +02:00
|
|
|
dpa = pDPA_Create(0);
|
|
|
|
ok(dpa != NULL, "\n");
|
|
|
|
|
|
|
|
/* Set item with out of bound index */
|
|
|
|
ok(pDPA_SetPtr(dpa, 1, (PVOID)6), "\n");
|
2008-01-23 23:05:21 +01:00
|
|
|
/* Fill the created gap */
|
2005-07-03 14:02:09 +02:00
|
|
|
ok(pDPA_SetPtr(dpa, 0, (PVOID)5), "\n");
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa, 0x56, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
/* Prepend item */
|
|
|
|
ret = pDPA_InsertPtr(dpa, 1, (PVOID)1);
|
|
|
|
ok(ret == 1, "ret=%d\n", ret);
|
|
|
|
/* Append item using correct index */
|
|
|
|
ret = pDPA_InsertPtr(dpa, 3, (PVOID)3);
|
|
|
|
ok(ret == 3, "ret=%d\n", ret);
|
|
|
|
/* Append item using out of bound index */
|
|
|
|
ret = pDPA_InsertPtr(dpa, 5, (PVOID)2);
|
2005-07-08 13:30:28 +02:00
|
|
|
ok(ret == 4, "ret=%d\n", ret);
|
2005-07-03 14:02:09 +02:00
|
|
|
/* Append item using DPA_APPEND */
|
|
|
|
ret = pDPA_InsertPtr(dpa, DPA_APPEND, (PVOID)4);
|
2005-07-08 13:30:28 +02:00
|
|
|
ok(ret == 5, "ret=%d\n", ret);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa, 0x516324, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
for(i = 1; i <= 6; i++)
|
|
|
|
{
|
|
|
|
INT j, k;
|
2009-01-03 20:13:20 +01:00
|
|
|
k = pDPA_GetPtrIndex(dpa, (PVOID)(INT_PTR)i);
|
2005-07-03 14:02:09 +02:00
|
|
|
/* Linear searches should work on unsorted DPAs */
|
2011-10-05 16:18:40 +02:00
|
|
|
j = pDPA_Search(dpa, (PVOID)(INT_PTR)i, 0, CB_CmpLT, 0x1abe11ed, 0);
|
2005-07-03 14:02:09 +02:00
|
|
|
ok(j == k, "j=%d k=%d\n", j, k);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sort DPA */
|
2011-10-05 16:18:40 +02:00
|
|
|
ok(pDPA_Sort(dpa, CB_CmpGT, 0x1abe11ed), "\n");
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa, 0x654321, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
/* Clone into a new DPA */
|
|
|
|
dpa2 = pDPA_Clone(dpa, NULL);
|
|
|
|
ok(dpa2 != NULL, "\n");
|
|
|
|
/* The old data should have been preserved */
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa2, 0x654321, &dw2);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw2);
|
2011-10-05 16:18:40 +02:00
|
|
|
ok(pDPA_Sort(dpa, CB_CmpLT, 0x1abe11ed), "\n");
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
/* Test if the DPA itself was really copied */
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa, 0x123456, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw );
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa2, 0x654321, &dw2);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw2=0x%lx\n", dw2);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
/* Clone into an old DPA */
|
2014-10-31 03:32:04 +01:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
2005-07-03 14:02:09 +02:00
|
|
|
p = pDPA_Clone(dpa, dpa3);
|
|
|
|
ok(p == dpa3, "p=%p\n", p);
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa3, 0x123456, &dw3);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw3=0x%lx\n", dw3);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
for(i = 1; i <= 6; i++)
|
|
|
|
{
|
|
|
|
INT j;
|
|
|
|
|
|
|
|
/* The array is in order so ptr == index+1 */
|
2009-01-03 20:13:20 +01:00
|
|
|
j = pDPA_GetPtrIndex(dpa, (PVOID)(INT_PTR)i);
|
2005-07-03 14:02:09 +02:00
|
|
|
ok(j+1 == i, "j=%d i=%d\n", j, i);
|
2011-10-05 16:18:40 +02:00
|
|
|
j = pDPA_Search(dpa, (PVOID)(INT_PTR)i, 0, CB_CmpLT, 0x1abe11ed, DPAS_SORTED);
|
2005-08-01 11:18:23 +02:00
|
|
|
ok(j+1 == i, "j=%d i=%d\n", j, i);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
/* Linear searches respect iStart ... */
|
2011-10-05 16:18:40 +02:00
|
|
|
j = pDPA_Search(dpa, (PVOID)(INT_PTR)i, i+1, CB_CmpLT, 0x1abe11ed, 0);
|
2005-07-03 14:02:09 +02:00
|
|
|
ok(j == DPA_ERR, "j=%d\n", j);
|
|
|
|
/* ... but for a binary search it's ignored */
|
2011-10-05 16:18:40 +02:00
|
|
|
j = pDPA_Search(dpa, (PVOID)(INT_PTR)i, i+1, CB_CmpLT, 0x1abe11ed, DPAS_SORTED);
|
2009-07-15 21:59:25 +02:00
|
|
|
ok(j+1 == i, "j=%d i=%d\n", j, i);
|
2005-07-03 14:02:09 +02:00
|
|
|
}
|
2009-07-15 21:59:25 +02:00
|
|
|
|
2005-07-11 12:59:41 +02:00
|
|
|
/* Try to get the index of a nonexistent item */
|
2005-07-03 14:02:09 +02:00
|
|
|
i = pDPA_GetPtrIndex(dpa, (PVOID)7);
|
|
|
|
ok(i == DPA_ERR, "i=%d\n", i);
|
|
|
|
|
|
|
|
/* Try to delete out of bound indexes */
|
|
|
|
p = pDPA_DeletePtr(dpa, -1);
|
|
|
|
ok(p == NULL, "p=%p\n", p);
|
|
|
|
p = pDPA_DeletePtr(dpa, 6);
|
|
|
|
ok(p == NULL, "p=%p\n", p);
|
|
|
|
|
|
|
|
/* Delete the third item */
|
|
|
|
p = pDPA_DeletePtr(dpa, 2);
|
|
|
|
ok(p == (PVOID)3, "p=%p\n", p);
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa, 0x12456, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
/* Check where to re-insert the deleted item */
|
|
|
|
i = pDPA_Search(dpa, (PVOID)3, 0,
|
2011-10-05 16:18:40 +02:00
|
|
|
CB_CmpLT, 0x1abe11ed, DPAS_SORTED|DPAS_INSERTAFTER);
|
2005-07-03 14:02:09 +02:00
|
|
|
ok(i == 2, "i=%d\n", i);
|
|
|
|
/* DPAS_INSERTBEFORE works just like DPAS_INSERTAFTER */
|
|
|
|
i = pDPA_Search(dpa, (PVOID)3, 0,
|
2011-10-05 16:18:40 +02:00
|
|
|
CB_CmpLT, 0x1abe11ed, DPAS_SORTED|DPAS_INSERTBEFORE);
|
2005-07-08 13:30:28 +02:00
|
|
|
ok(i == 2, "i=%d\n", i);
|
2005-08-01 16:50:36 +02:00
|
|
|
/* without DPAS_INSERTBEFORE/AFTER */
|
|
|
|
i = pDPA_Search(dpa, (PVOID)3, 0,
|
2011-10-05 16:18:40 +02:00
|
|
|
CB_CmpLT, 0x1abe11ed, DPAS_SORTED);
|
2005-08-01 16:50:36 +02:00
|
|
|
ok(i == -1, "i=%d\n", i);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
/* Re-insert the item */
|
|
|
|
ret = pDPA_InsertPtr(dpa, 2, (PVOID)3);
|
|
|
|
ok(ret == 2, "ret=%d i=%d\n", ret, 2);
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa, 0x123456, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
|
|
|
/* When doing a binary search while claiming reverse order all indexes
|
|
|
|
* should be bogus */
|
|
|
|
for(i = 0; i < 6; i++)
|
|
|
|
{
|
2011-10-05 16:18:40 +02:00
|
|
|
INT j = pDPA_Search(dpa, (PVOID)(INT_PTR)i, 0, CB_CmpGT, 0x1abe11ed,
|
2005-07-03 14:02:09 +02:00
|
|
|
DPAS_SORTED|DPAS_INSERTBEFORE);
|
|
|
|
ok(j != i, "i=%d\n", i);
|
|
|
|
}
|
|
|
|
|
2005-07-07 13:26:26 +02:00
|
|
|
/* Setting item with huge index should work */
|
2005-07-08 13:30:28 +02:00
|
|
|
ok(pDPA_SetPtr(dpa2, 0x12345, (PVOID)0xdeadbeef), "\n");
|
2005-07-07 13:26:26 +02:00
|
|
|
ret = pDPA_GetPtrIndex(dpa2, (PVOID)0xdeadbeef);
|
2005-07-08 13:30:28 +02:00
|
|
|
ok(ret == 0x12345, "ret=%d\n", ret);
|
2005-07-07 13:26:26 +02:00
|
|
|
|
2005-07-03 14:02:09 +02:00
|
|
|
pDPA_DeleteAllPtrs(dpa2);
|
2006-11-23 21:37:08 +01:00
|
|
|
rc=CheckDPA(dpa2, 0, &dw2);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw2=0x%lx\n", dw2);
|
2009-12-05 19:21:04 +01:00
|
|
|
|
|
|
|
pDPA_Destroy(dpa);
|
2005-07-03 14:02:09 +02:00
|
|
|
pDPA_Destroy(dpa2);
|
2009-09-09 21:15:32 +02:00
|
|
|
pDPA_Destroy(dpa3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_DPA_Merge(void)
|
|
|
|
{
|
|
|
|
HDPA dpa, dpa2, dpa3;
|
|
|
|
INT ret, i;
|
|
|
|
DWORD dw;
|
|
|
|
BOOL rc;
|
|
|
|
|
|
|
|
dpa = pDPA_Create(0);
|
|
|
|
dpa2 = pDPA_Create(0);
|
|
|
|
dpa3 = pDPA_Create(0);
|
|
|
|
|
|
|
|
ret = pDPA_InsertPtr(dpa, 0, (PVOID)1);
|
|
|
|
ok(ret == 0, "ret=%d\n", ret);
|
|
|
|
ret = pDPA_InsertPtr(dpa, 1, (PVOID)3);
|
|
|
|
ok(ret == 1, "ret=%d\n", ret);
|
|
|
|
ret = pDPA_InsertPtr(dpa, 2, (PVOID)5);
|
|
|
|
ok(ret == 2, "ret=%d\n", ret);
|
|
|
|
|
|
|
|
rc = CheckDPA(dpa, 0x135, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-09 21:15:32 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
2009-10-01 22:26:17 +02:00
|
|
|
ret = pDPA_InsertPtr(dpa2, i, (PVOID)(INT_PTR)(6-i));
|
2009-09-09 21:15:32 +02:00
|
|
|
ok(ret == i, "ret=%d\n", ret);
|
2009-10-01 22:26:17 +02:00
|
|
|
ret = pDPA_InsertPtr(dpa3, i, (PVOID)(INT_PTR)(i+1));
|
2009-09-09 21:15:32 +02:00
|
|
|
ok(ret == i, "ret=%d\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = CheckDPA(dpa2, 0x654321, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-09 21:15:32 +02:00
|
|
|
rc = CheckDPA(dpa3, 0x123456, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-09 21:15:32 +02:00
|
|
|
|
|
|
|
/* Delete all odd entries from dpa2 */
|
2009-09-10 20:17:09 +02:00
|
|
|
memset(nMessages, 0, sizeof(nMessages));
|
2009-09-09 22:02:55 +02:00
|
|
|
pDPA_Merge(dpa2, dpa, DPAM_INTERSECT,
|
2011-10-05 16:18:40 +02:00
|
|
|
CB_CmpLT, CB_MergeDeleteOddSrc, 0x1abe11ed);
|
2009-09-10 20:56:56 +02:00
|
|
|
rc = CheckDPA(dpa2, 0x246, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-10 20:56:56 +02:00
|
|
|
|
2009-09-10 20:17:09 +02:00
|
|
|
expect(3, nMessages[DPAMM_MERGE]);
|
|
|
|
expect(3, nMessages[DPAMM_DELETE]);
|
|
|
|
expect(0, nMessages[DPAMM_INSERT]);
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
2009-10-01 22:26:17 +02:00
|
|
|
ret = pDPA_InsertPtr(dpa2, i, (PVOID)(INT_PTR)(6-i));
|
2009-09-10 20:17:09 +02:00
|
|
|
ok(ret == i, "ret=%d\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DPAM_INTERSECT - returning source while merging */
|
|
|
|
memset(nMessages, 0, sizeof(nMessages));
|
|
|
|
pDPA_Merge(dpa2, dpa, DPAM_INTERSECT,
|
2011-10-05 16:18:40 +02:00
|
|
|
CB_CmpLT, CB_MergeInsertSrc, 0x1abe11ed);
|
2009-09-10 20:56:56 +02:00
|
|
|
rc = CheckDPA(dpa2, 0x135, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-10 20:56:56 +02:00
|
|
|
|
2009-09-10 20:17:09 +02:00
|
|
|
expect(3, nMessages[DPAMM_MERGE]);
|
|
|
|
expect(6, nMessages[DPAMM_DELETE]);
|
|
|
|
expect(0, nMessages[DPAMM_INSERT]);
|
|
|
|
|
|
|
|
/* DPAM_UNION */
|
|
|
|
pDPA_DeleteAllPtrs(dpa);
|
|
|
|
pDPA_InsertPtr(dpa, 0, (PVOID)1);
|
|
|
|
pDPA_InsertPtr(dpa, 1, (PVOID)3);
|
|
|
|
pDPA_InsertPtr(dpa, 2, (PVOID)5);
|
|
|
|
pDPA_DeleteAllPtrs(dpa2);
|
|
|
|
pDPA_InsertPtr(dpa2, 0, (PVOID)2);
|
|
|
|
pDPA_InsertPtr(dpa2, 1, (PVOID)4);
|
|
|
|
pDPA_InsertPtr(dpa2, 2, (PVOID)6);
|
|
|
|
|
|
|
|
memset(nMessages, 0, sizeof(nMessages));
|
|
|
|
pDPA_Merge(dpa2, dpa, DPAM_UNION,
|
2011-10-05 16:18:40 +02:00
|
|
|
CB_CmpLT, CB_MergeInsertSrc, 0x1abe11ed);
|
2009-09-10 20:17:09 +02:00
|
|
|
rc = CheckDPA(dpa2, 0x123456, &dw);
|
2009-09-13 19:56:48 +02:00
|
|
|
ok(rc ||
|
|
|
|
broken(!rc && dw == 0x23456), /* 4.7x */
|
2022-02-28 08:25:25 +01:00
|
|
|
"dw=0x%lx\n", dw);
|
2009-09-10 20:17:09 +02:00
|
|
|
|
|
|
|
expect(0, nMessages[DPAMM_MERGE]);
|
|
|
|
expect(0, nMessages[DPAMM_DELETE]);
|
2009-09-13 19:56:48 +02:00
|
|
|
ok(nMessages[DPAMM_INSERT] == 3 ||
|
|
|
|
broken(nMessages[DPAMM_INSERT] == 2), /* 4.7x */
|
|
|
|
"Expected 3, got %d\n", nMessages[DPAMM_INSERT]);
|
2009-09-09 21:15:32 +02:00
|
|
|
|
|
|
|
/* Merge dpa3 into dpa2 and dpa */
|
2009-09-10 20:17:09 +02:00
|
|
|
memset(nMessages, 0, sizeof(nMessages));
|
2009-09-09 22:02:55 +02:00
|
|
|
pDPA_Merge(dpa, dpa3, DPAM_UNION|DPAM_SORTED,
|
2011-10-05 16:18:40 +02:00
|
|
|
CB_CmpLT, CB_MergeInsertSrc, 0x1abe11ed);
|
2009-09-10 20:17:09 +02:00
|
|
|
expect(3, nMessages[DPAMM_MERGE]);
|
|
|
|
expect(0, nMessages[DPAMM_DELETE]);
|
|
|
|
expect(3, nMessages[DPAMM_INSERT]);
|
|
|
|
|
|
|
|
|
|
|
|
pDPA_DeleteAllPtrs(dpa2);
|
|
|
|
pDPA_InsertPtr(dpa2, 0, (PVOID)2);
|
|
|
|
pDPA_InsertPtr(dpa2, 1, (PVOID)4);
|
|
|
|
pDPA_InsertPtr(dpa2, 2, (PVOID)6);
|
|
|
|
|
|
|
|
memset(nMessages, 0, sizeof(nMessages));
|
2009-09-09 22:02:55 +02:00
|
|
|
pDPA_Merge(dpa2, dpa3, DPAM_UNION|DPAM_SORTED,
|
2011-10-05 16:18:40 +02:00
|
|
|
CB_CmpLT, CB_MergeInsertSrc, 0x1abe11ed);
|
2009-09-10 20:17:09 +02:00
|
|
|
expect(3, nMessages[DPAMM_MERGE]);
|
|
|
|
expect(0, nMessages[DPAMM_DELETE]);
|
2009-09-13 19:56:48 +02:00
|
|
|
ok(nMessages[DPAMM_INSERT] == 3 ||
|
|
|
|
broken(nMessages[DPAMM_INSERT] == 2), /* 4.7x */
|
|
|
|
"Expected 3, got %d\n", nMessages[DPAMM_INSERT]);
|
2009-09-09 21:15:32 +02:00
|
|
|
|
|
|
|
rc = CheckDPA(dpa, 0x123456, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-09 21:15:32 +02:00
|
|
|
rc = CheckDPA(dpa2, 0x123456, &dw);
|
|
|
|
ok(rc ||
|
|
|
|
broken(!rc), /* win98 */
|
2022-02-28 08:25:25 +01:00
|
|
|
"dw=0x%lx\n", dw);
|
2009-09-09 21:15:32 +02:00
|
|
|
rc = CheckDPA(dpa3, 0x123456, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-09 21:15:32 +02:00
|
|
|
|
|
|
|
pDPA_Destroy(dpa);
|
|
|
|
pDPA_Destroy(dpa2);
|
|
|
|
pDPA_Destroy(dpa3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_DPA_EnumCallback(void)
|
|
|
|
{
|
|
|
|
HDPA dpa;
|
|
|
|
BOOL rc;
|
|
|
|
DWORD dw;
|
|
|
|
INT i, ret;
|
|
|
|
|
|
|
|
dpa = pDPA_Create(0);
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
2009-10-01 22:26:17 +02:00
|
|
|
ret = pDPA_InsertPtr(dpa, i, (PVOID)(INT_PTR)(i+1));
|
2009-09-09 21:15:32 +02:00
|
|
|
ok(ret == i, "ret=%d\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = CheckDPA(dpa, 0x123456, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-09 21:15:32 +02:00
|
|
|
|
|
|
|
nEnum = 0;
|
|
|
|
/* test callback sets first 3 items to 7 */
|
|
|
|
pDPA_EnumCallback(dpa, CB_EnumFirstThree, dpa);
|
|
|
|
rc = CheckDPA(dpa, 0x777456, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-09 21:15:32 +02:00
|
|
|
ok(nEnum == 3, "nEnum=%d\n", nEnum);
|
|
|
|
|
|
|
|
pDPA_Destroy(dpa);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_DPA_DestroyCallback(void)
|
|
|
|
{
|
|
|
|
HDPA dpa;
|
|
|
|
INT i, ret;
|
|
|
|
|
|
|
|
dpa = pDPA_Create(0);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
2009-09-09 21:15:32 +02:00
|
|
|
for (i = 0; i < 3; i++)
|
2005-07-03 14:02:09 +02:00
|
|
|
{
|
2009-10-01 22:26:17 +02:00
|
|
|
ret = pDPA_InsertPtr(dpa, i, (PVOID)(INT_PTR)(i+1));
|
2009-09-09 21:15:32 +02:00
|
|
|
ok(ret == i, "ret=%d\n", ret);
|
2005-07-03 14:02:09 +02:00
|
|
|
}
|
2009-09-09 21:15:32 +02:00
|
|
|
|
|
|
|
nEnum = 0;
|
|
|
|
pDPA_DestroyCallback(dpa, CB_EnumFirstThree, dpa);
|
|
|
|
ok(nEnum == 3, "nEnum=%d\n", nEnum);
|
|
|
|
}
|
|
|
|
|
2009-09-12 01:17:54 +02:00
|
|
|
static void test_DPA_LoadStream(void)
|
|
|
|
{
|
|
|
|
IStorage* pStg = NULL;
|
|
|
|
IStream* pStm = NULL;
|
|
|
|
LARGE_INTEGER li;
|
|
|
|
ULARGE_INTEGER uli;
|
|
|
|
DWORD dwMode;
|
|
|
|
HRESULT hRes;
|
|
|
|
STREAMDATA header;
|
|
|
|
ULONG written, ret;
|
|
|
|
HDPA dpa;
|
|
|
|
|
|
|
|
hRes = CoInitialize(NULL);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(hRes == S_OK, "Failed to initialize COM, hr %#lx.\n", hRes);
|
2009-09-12 01:17:54 +02:00
|
|
|
|
|
|
|
dwMode = STGM_DIRECT|STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE;
|
|
|
|
hRes = StgCreateDocfile(NULL, dwMode|STGM_DELETEONRELEASE, 0, &pStg);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
2020-09-25 09:36:17 +02:00
|
|
|
hRes = IStorage_CreateStream(pStg, L"Stg", dwMode, 0, 0, &pStm);
|
2009-09-12 01:17:54 +02:00
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
|
|
|
/* write less than header size */
|
|
|
|
li.QuadPart = 0;
|
|
|
|
hRes = IStream_Seek(pStm, li, STREAM_SEEK_SET, NULL);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
|
|
|
memset(&header, 0, sizeof(header));
|
|
|
|
written = 0;
|
|
|
|
uli.QuadPart = sizeof(header)-1;
|
|
|
|
hRes = IStream_SetSize(pStm, uli);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
hRes = IStream_Write(pStm, &header, sizeof(header)-1, &written);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
written -= sizeof(header)-1;
|
|
|
|
expect(0, written);
|
|
|
|
|
|
|
|
li.QuadPart = 0;
|
|
|
|
hRes = IStream_Seek(pStm, li, STREAM_SEEK_SET, NULL);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
|
|
|
hRes = pDPA_LoadStream(&dpa, CB_Load, pStm, NULL);
|
|
|
|
expect(E_FAIL, hRes);
|
|
|
|
|
|
|
|
/* check stream position after header read failed */
|
|
|
|
li.QuadPart = 0;
|
|
|
|
uli.QuadPart = 1;
|
|
|
|
hRes = IStream_Seek(pStm, li, STREAM_SEEK_CUR, &uli);
|
|
|
|
expect(S_OK, hRes);
|
2009-09-12 01:32:02 +02:00
|
|
|
ok(uli.QuadPart == 0, "Expected to position reset\n");
|
2009-09-12 01:17:54 +02:00
|
|
|
|
|
|
|
/* write valid header for empty DPA */
|
|
|
|
header.dwSize = sizeof(header);
|
|
|
|
header.dwData2 = 1;
|
|
|
|
header.dwItems = 0;
|
|
|
|
written = 0;
|
|
|
|
|
|
|
|
li.QuadPart = 0;
|
|
|
|
hRes = IStream_Seek(pStm, li, STREAM_SEEK_SET, NULL);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
|
|
|
uli.QuadPart = sizeof(header);
|
|
|
|
hRes = IStream_SetSize(pStm, uli);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
|
|
|
hRes = IStream_Write(pStm, &header, sizeof(header), &written);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
written -= sizeof(header);
|
|
|
|
expect(0, written);
|
|
|
|
|
|
|
|
li.QuadPart = 0;
|
|
|
|
hRes = IStream_Seek(pStm, li, STREAM_SEEK_SET, NULL);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
2009-12-05 19:21:04 +01:00
|
|
|
dpa = NULL;
|
2009-09-12 01:17:54 +02:00
|
|
|
hRes = pDPA_LoadStream(&dpa, CB_Load, pStm, NULL);
|
2009-09-12 01:32:02 +02:00
|
|
|
expect(S_OK, hRes);
|
2018-01-24 13:47:09 +01:00
|
|
|
pDPA_Destroy(dpa);
|
2009-09-12 01:17:54 +02:00
|
|
|
|
|
|
|
/* try with altered dwData2 field */
|
|
|
|
header.dwSize = sizeof(header);
|
|
|
|
header.dwData2 = 2;
|
|
|
|
header.dwItems = 0;
|
|
|
|
|
|
|
|
li.QuadPart = 0;
|
|
|
|
hRes = IStream_Seek(pStm, li, STREAM_SEEK_SET, NULL);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
hRes = IStream_Write(pStm, &header, sizeof(header), &written);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
written -= sizeof(header);
|
|
|
|
expect(0, written);
|
|
|
|
|
|
|
|
li.QuadPart = 0;
|
|
|
|
hRes = IStream_Seek(pStm, li, STREAM_SEEK_SET, NULL);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
|
|
|
hRes = pDPA_LoadStream(&dpa, CB_Load, pStm, (void*)0xdeadbeef);
|
2009-09-12 01:32:02 +02:00
|
|
|
expect(E_FAIL, hRes);
|
2009-09-12 01:17:54 +02:00
|
|
|
|
|
|
|
ret = IStream_Release(pStm);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(!ret, "ret=%ld\n", ret);
|
2009-09-12 01:17:54 +02:00
|
|
|
|
|
|
|
ret = IStorage_Release(pStg);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(!ret, "ret=%ld\n", ret);
|
2009-09-12 01:17:54 +02:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|
|
|
|
|
2009-09-14 09:16:06 +02:00
|
|
|
static void test_DPA_SaveStream(void)
|
|
|
|
{
|
|
|
|
HDPA dpa;
|
|
|
|
IStorage* pStg = NULL;
|
|
|
|
IStream* pStm = NULL;
|
2009-09-16 11:00:40 +02:00
|
|
|
DWORD dwMode, dw;
|
2009-09-14 09:16:06 +02:00
|
|
|
HRESULT hRes;
|
2011-10-05 16:18:40 +02:00
|
|
|
INT ret;
|
2009-09-16 11:00:40 +02:00
|
|
|
INT i;
|
|
|
|
BOOL rc;
|
|
|
|
LARGE_INTEGER liZero;
|
2009-09-14 09:16:06 +02:00
|
|
|
|
|
|
|
hRes = CoInitialize(NULL);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(hRes == S_OK, "Failed to initialize COM, hr %#lx.\n", hRes);
|
2009-09-14 09:16:06 +02:00
|
|
|
|
|
|
|
dwMode = STGM_DIRECT|STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE;
|
|
|
|
hRes = StgCreateDocfile(NULL, dwMode|STGM_DELETEONRELEASE, 0, &pStg);
|
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
2020-09-25 09:36:17 +02:00
|
|
|
hRes = IStorage_CreateStream(pStg, L"Stg", dwMode, 0, 0, &pStm);
|
2009-09-14 09:16:06 +02:00
|
|
|
expect(S_OK, hRes);
|
|
|
|
|
|
|
|
dpa = pDPA_Create(0);
|
|
|
|
|
|
|
|
/* simple parameter check */
|
|
|
|
hRes = pDPA_SaveStream(dpa, NULL, pStm, NULL);
|
|
|
|
ok(hRes == E_INVALIDARG ||
|
2022-02-28 08:25:25 +01:00
|
|
|
broken(hRes == S_OK) /* XP and below */, "Wrong result, %ld\n", hRes);
|
2009-09-14 09:16:06 +02:00
|
|
|
if (0) {
|
|
|
|
/* crashes on XP */
|
|
|
|
hRes = pDPA_SaveStream(NULL, CB_Save, pStm, NULL);
|
|
|
|
expect(E_INVALIDARG, hRes);
|
|
|
|
|
|
|
|
hRes = pDPA_SaveStream(dpa, CB_Save, NULL, NULL);
|
|
|
|
expect(E_INVALIDARG, hRes);
|
|
|
|
}
|
|
|
|
|
2009-09-16 11:00:40 +02:00
|
|
|
/* saving/loading */
|
2009-09-09 21:15:32 +02:00
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
2009-10-01 22:26:17 +02:00
|
|
|
ret = pDPA_InsertPtr(dpa, i, (PVOID)(INT_PTR)(i+1));
|
2009-09-09 21:15:32 +02:00
|
|
|
ok(ret == i, "ret=%d\n", ret);
|
|
|
|
}
|
2005-07-03 14:02:09 +02:00
|
|
|
|
2009-09-16 11:00:40 +02:00
|
|
|
liZero.QuadPart = 0;
|
|
|
|
hRes = IStream_Seek(pStm, liZero, STREAM_SEEK_SET, NULL);
|
2009-09-14 09:16:06 +02:00
|
|
|
expect(S_OK, hRes);
|
2005-07-03 14:02:09 +02:00
|
|
|
|
2009-09-12 01:17:54 +02:00
|
|
|
hRes = pDPA_SaveStream(dpa, CB_Save, pStm, (void*)0xdeadbeef);
|
2009-09-16 11:00:40 +02:00
|
|
|
expect(S_OK, hRes);
|
2005-07-03 14:02:09 +02:00
|
|
|
pDPA_Destroy(dpa);
|
2009-09-09 21:15:32 +02:00
|
|
|
|
|
|
|
liZero.QuadPart = 0;
|
|
|
|
hRes = IStream_Seek(pStm, liZero, STREAM_SEEK_SET, NULL);
|
2009-09-14 09:16:06 +02:00
|
|
|
expect(S_OK, hRes);
|
2009-09-12 01:17:54 +02:00
|
|
|
hRes = pDPA_LoadStream(&dpa, CB_Load, pStm, (void*)0xdeadbeef);
|
2009-09-14 09:16:06 +02:00
|
|
|
expect(S_OK, hRes);
|
|
|
|
rc = CheckDPA(dpa, 0x123456, &dw);
|
2022-02-28 08:25:25 +01:00
|
|
|
ok(rc, "dw=0x%lx\n", dw);
|
2009-09-09 21:15:32 +02:00
|
|
|
pDPA_Destroy(dpa);
|
|
|
|
|
|
|
|
ret = IStream_Release(pStm);
|
|
|
|
ok(!ret, "ret=%d\n", ret);
|
|
|
|
|
|
|
|
ret = IStorage_Release(pStg);
|
|
|
|
ok(!ret, "ret=%d\n", ret);
|
|
|
|
|
|
|
|
CoUninitialize();
|
2003-05-16 01:58:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(dpa)
|
|
|
|
{
|
2018-01-29 12:20:42 +01:00
|
|
|
ULONG_PTR cookie;
|
|
|
|
HANDLE ctxt;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
init_functions();
|
2009-09-09 21:15:32 +02:00
|
|
|
|
|
|
|
test_dpa();
|
|
|
|
test_DPA_Merge();
|
|
|
|
test_DPA_EnumCallback();
|
|
|
|
test_DPA_DestroyCallback();
|
2009-09-12 01:17:54 +02:00
|
|
|
test_DPA_LoadStream();
|
2009-09-14 09:16:06 +02:00
|
|
|
test_DPA_SaveStream();
|
2018-01-29 12:20:42 +01:00
|
|
|
|
|
|
|
if (!load_v6_module(&cookie, &ctxt))
|
|
|
|
return;
|
|
|
|
|
|
|
|
init_functions();
|
|
|
|
|
|
|
|
test_dpa();
|
|
|
|
test_DPA_Merge();
|
|
|
|
test_DPA_EnumCallback();
|
|
|
|
test_DPA_DestroyCallback();
|
|
|
|
test_DPA_LoadStream();
|
|
|
|
test_DPA_SaveStream();
|
|
|
|
|
|
|
|
unload_v6_module(cookie, ctxt);
|
2003-05-16 01:58:48 +02:00
|
|
|
}
|