Fixed VarBstrCmp/Cat .spec entries.

Started regression test for SafeArray functions.
Fixed SafeArrayAllocDescriptor (check bounds, set cDims).
Fixed VARTYPE_SIZE array entries so it matches native.
This commit is contained in:
Marcus Meissner 2002-12-23 02:02:49 +00:00 committed by Alexandre Julliard
parent 3d2e380244
commit 7c290abd85
5 changed files with 170 additions and 18 deletions

View File

@ -305,8 +305,8 @@
310 stub VarCyRound
311 stub VarCyCmp
312 stub VarCyCmpR8
313 stdcall VarBstrCat(ptr ptr ptr) VarBstrCat
314 stdcall VarBstrCmp(ptr ptr long long) VarBstrCmp
313 stdcall VarBstrCat(wstr wstr ptr) VarBstrCat
314 stdcall VarBstrCmp(wstr wstr long long) VarBstrCmp
315 stub VarR8Pow # stdcall (double double ptr)
316 stub VarR4CmpR8
317 stub VarR8Round # stdcall (double long ptr)

View File

@ -79,19 +79,19 @@ VARTYPE_NOT_SUPPORTED, /* VT_NULL [V] [P] SQL style Nul */
sizeof(BSTR), /* VT_BSTR [V][T][P][S] OLE Automation string*/
sizeof(LPDISPATCH), /* VT_DISPATCH [V][T][P][S] IDispatch * */
4, /* VT_ERROR [V][T] [S] SCODE */
4, /* VT_BOOL [V][T][P][S] True=-1, False=0*/
2, /* VT_BOOL [V][T][P][S] True=-1, False=0*/
sizeof(VARIANT), /* VT_VARIANT [V][T][P][S] VARIANT * */
sizeof(LPUNKNOWN), /* VT_UNKNOWN [V][T] [S] IUnknown * */
sizeof(DECIMAL), /* VT_DECIMAL [V][T] [S] 16 byte fixed point */
VARTYPE_NOT_SUPPORTED, /* no VARTYPE here..... */
VARTYPE_NOT_SUPPORTED, /* VT_I1 [T] signed char */
1, /* VT_I1 [T] [S] signed char */
1, /* VT_UI1 [V][T][P][S] unsigned char */
VARTYPE_NOT_SUPPORTED, /* VT_UI2 [T][P] unsigned short */
VARTYPE_NOT_SUPPORTED, /* VT_UI4 [T][P] unsigned short */
2, /* VT_UI2 [T][P][S] unsigned short */
4, /* VT_UI4 [T][P][S] unsigned int */
VARTYPE_NOT_SUPPORTED, /* VT_I8 [T][P] signed 64-bit int */
VARTYPE_NOT_SUPPORTED, /* VT_UI8 [T][P] unsigned 64-bit int */
VARTYPE_NOT_SUPPORTED, /* VT_INT [T] signed machine int */
VARTYPE_NOT_SUPPORTED, /* VT_UINT [T] unsigned machine int */
sizeof(INT), /* VT_INT [T] signed machine int */
sizeof(UINT), /* VT_UINT [T] unsigned machine int */
VARTYPE_NOT_SUPPORTED, /* VT_VOID [T] C style void */
VARTYPE_NOT_SUPPORTED, /* VT_HRESULT [T] Standard return type */
VARTYPE_NOT_SUPPORTED, /* VT_PTR [T] pointer type */
@ -128,6 +128,12 @@ HRESULT WINAPI SafeArrayAllocDescriptor(
SAFEARRAYBOUND *sab;
LONG allocSize = 0;
if (!cDims || cDims >= 0x10000) /* 65536 appears to be the limit */
return E_INVALIDARG;
if (!ppsaOut)
return E_POINTER;
/* SAFEARRAY + SAFEARRAYBOUND * (cDims -1) ( -1 because there is already one
( in SAFEARRAY struct */
allocSize = sizeof(**ppsaOut) + (sizeof(*sab) * (cDims-1));
@ -137,7 +143,8 @@ HRESULT WINAPI SafeArrayAllocDescriptor(
GetProcessHeap(), HEAP_ZERO_MEMORY, allocSize)) == NULL){
return(E_UNEXPECTED);
}
TRACE("SafeArray: %lu bytes allocated for descriptor.\n", allocSize);
(*ppsaOut)->cDims = cDims;
TRACE("(%d): %lu bytes allocated for descriptor.\n", cDims, allocSize);
return(S_OK);
}
@ -1036,20 +1043,27 @@ static BOOL validCoordinate(
LONG lLBound;
HRESULT hRes;
if (!psa->cDims) return FALSE;
if (!psa->cDims) { FIXME("no dims?\n");return FALSE; }
for(; iter<psa->cDims; iter++) {
TRACE("coor[%d]=%ld\n", iter, coor[iter]);
if((hRes = SafeArrayGetLBound(psa, (iter+1), &lLBound)) != S_OK)
if((hRes = SafeArrayGetLBound(psa, (iter+1), &lLBound)) != S_OK) {
FIXME("No lbound?\n");
return FALSE;
if((hRes = SafeArrayGetUBound(psa, (iter+1), &lUBound)) != S_OK)
}
if((hRes = SafeArrayGetUBound(psa, (iter+1), &lUBound)) != S_OK) {
FIXME("No ubound?\n");
return FALSE;
}
if(lLBound > lUBound) {
FIXME("lbound larger than ubound?\n");
return FALSE;
}
if(lLBound > lUBound)
return FALSE;
if((coor[iter] < lLBound) || (coor[iter] > lUBound))
if((coor[iter] < lLBound) || (coor[iter] > lUBound)) {
FIXME("coordinate %ld not within %ld - %ld\n",coor[iter], lLBound, lUBound);
return FALSE;
}
}
return TRUE;
}

View File

@ -1,4 +1,5 @@
Makefile
oleaut32_test.exe.spec.c
safearray.ok
testlist.c
vartest.ok

View File

@ -6,6 +6,7 @@ TESTDLL = oleaut32.dll
IMPORTS = oleaut32
CTESTS = \
safearray.c \
vartest.c
@MAKE_TEST_RULES@

View File

@ -0,0 +1,136 @@
/*
* SafeArray test program
*
* Copyright 2002 Marcus Meissner
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <time.h>
#include "wine/test.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "winnls.h"
#include "winerror.h"
#include "winnt.h"
#include "wtypes.h"
#include "oleauto.h"
#define VARTYPE_NOT_SUPPORTED 0
static int vttypes[] = {
/* this is taken from wtypes.h. Only [S]es are supported by the SafeArray */
VARTYPE_NOT_SUPPORTED, /* VT_EMPTY [V] [P] nothing */
VARTYPE_NOT_SUPPORTED, /* VT_NULL [V] [P] SQL style Nul */
2, /* VT_I2 [V][T][P][S] 2 byte signed int */
4, /* VT_I4 [V][T][P][S] 4 byte signed int */
4, /* VT_R4 [V][T][P][S] 4 byte real */
8, /* VT_R8 [V][T][P][S] 8 byte real */
8, /* VT_CY [V][T][P][S] currency */
8, /* VT_DATE [V][T][P][S] date */
sizeof(BSTR), /* VT_BSTR [V][T][P][S] OLE Automation string*/
sizeof(LPDISPATCH), /* VT_DISPATCH [V][T][P][S] IDispatch * */
4, /* VT_ERROR [V][T] [S] SCODE */
2, /* VT_BOOL [V][T][P][S] True=-1, False=0*/
sizeof(VARIANT), /* VT_VARIANT [V][T][P][S] VARIANT * */
sizeof(LPUNKNOWN), /* VT_UNKNOWN [V][T] [S] IUnknown * */
sizeof(DECIMAL), /* VT_DECIMAL [V][T] [S] 16 byte fixed point */
VARTYPE_NOT_SUPPORTED, /* no VARTYPE here..... */
1, /* VT_I1 [T] [S] signed char */
1, /* VT_UI1 [V][T][P][S] unsigned char */
2, /* VT_UI2 [T][P][S] unsigned short */
4, /* VT_UI4 [T][P][S] unsigned int */
VARTYPE_NOT_SUPPORTED, /* VT_I8 [T][P] signed 64-bit int */
VARTYPE_NOT_SUPPORTED, /* VT_UI8 [T][P] unsigned 64-bit int */
sizeof(INT), /* VT_INT [T] signed machine int */
sizeof(UINT), /* VT_UINT [T] unsigned machine int */
VARTYPE_NOT_SUPPORTED, /* VT_VOID [T] C style void */
VARTYPE_NOT_SUPPORTED, /* VT_HRESULT [T] Standard return type */
VARTYPE_NOT_SUPPORTED, /* VT_PTR [T] pointer type */
VARTYPE_NOT_SUPPORTED, /* VT_SAFEARRAY [T] (use VT_ARRAY in VARIANT)*/
VARTYPE_NOT_SUPPORTED, /* VT_CARRAY [T] C style array */
VARTYPE_NOT_SUPPORTED, /* VT_USERDEFINED [T] user defined type */
VARTYPE_NOT_SUPPORTED, /* VT_LPSTR [T][P] null terminated string */
VARTYPE_NOT_SUPPORTED, /* VT_LPWSTR [T][P] wide null term string */
VARTYPE_NOT_SUPPORTED, /* VT_FILETIME [P] FILETIME */
VARTYPE_NOT_SUPPORTED, /* VT_BLOB [P] Length prefixed bytes */
VARTYPE_NOT_SUPPORTED, /* VT_STREAM [P] Name of stream follows */
VARTYPE_NOT_SUPPORTED, /* VT_STORAGE [P] Name of storage follows */
VARTYPE_NOT_SUPPORTED, /* VT_STREAMED_OBJECT[P] Stream contains an object*/
VARTYPE_NOT_SUPPORTED, /* VT_STORED_OBJECT [P] Storage contains object*/
VARTYPE_NOT_SUPPORTED, /* VT_BLOB_OBJECT [P] Blob contains an object*/
VARTYPE_NOT_SUPPORTED, /* VT_CF [P] Clipboard format */
VARTYPE_NOT_SUPPORTED, /* VT_CLSID [P] A Class ID */
VARTYPE_NOT_SUPPORTED, /* VT_VECTOR [P] simple counted array */
VARTYPE_NOT_SUPPORTED, /* VT_ARRAY [V] SAFEARRAY* */
VARTYPE_NOT_SUPPORTED /* VT_BYREF [V] void* for local use */
};
START_TEST(safearray)
{
SAFEARRAY *a;
int i;
HRESULT hres;
SAFEARRAYBOUND bound;
hres = SafeArrayAllocDescriptor(0,&a);
ok(E_INVALIDARG == hres,"SAAD(0) failed with hres %lx",hres);
hres=SafeArrayAllocDescriptor(1,&a);
ok(S_OK == hres,"SAAD(1) failed with %lx",hres);
for (i=1;i<100;i++) {
hres=SafeArrayAllocDescriptor(i,&a);
ok(S_OK == hres,"SAAD(%d) failed with %lx\n",i,hres);
ok(a->cDims == i,"a->cDims not initialised?\n");
hres=SafeArrayDestroyDescriptor(a);
ok(S_OK == hres,"SADD failed with %lx\n",hres);
}
hres=SafeArrayAllocDescriptor(65535,&a);
ok(S_OK == hres,"SAAD(65535) failed with %lx",hres);
hres=SafeArrayDestroyDescriptor(a);
ok(S_OK == hres,"SADD failed with %lx",hres);
hres=SafeArrayAllocDescriptor(65536,&a);
ok(E_INVALIDARG == hres,"SAAD(65536) failed with %lx",hres);
hres=SafeArrayAllocDescriptor(1,NULL);
ok(E_POINTER == hres,"SAAD(1,NULL) failed with %lx",hres);
bound.cElements = 1;
bound.lLbound = 0;
a = SafeArrayCreate(-1, 1, &bound);
ok(NULL == a,"SAC(-1,1,[1,0]) not failed?\n");
for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) {
a = SafeArrayCreate(i, 1, &bound);
ok( ((a == NULL) && (vttypes[i] == 0)) ||
((a != NULL) && (vttypes[i] == a->cbElements)),
"SAC(%d,1,[1,0]), result %ld, expected %d\n",i,(a?a->cbElements:0),vttypes[i]
);
}
}