PATCH: safearray fixes and regtest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I started safearray regression tests, verifying results on the go 
between native and builtin oleaut32.dll. (Using:
	wine -dll oleaut32=n oleaut32_test.exe.so safearray
)
Some fixes done to SafeArrayAllocDescriptor and SafeArrayCreate.

dlls/oleaut32/tests/safearray.c is attached.

Ciao, Marcus

Changelog:
	Started writing SafeArray regression tests.
	Fixed SafeArrayAllocDescriptor and VARTYPE_SIZE according to native
	oleaut32.dll.

Index: dlls/oleaut32/safearray.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/safearray.c,v
retrieving revision 1.20
diff -u -u -r1.20 safearray.c
--- dlls/oleaut32/safearray.c	12 Dec 2002 22:59:07 -0000	1.20
+++ dlls/oleaut32/safearray.c	20 Dec 2002 20:25:42 -0000
@@ -79,19 +79,19 @@
 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_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	*/
+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		*/
-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 @@
   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,7 @@
         GetProcessHeap(), HEAP_ZERO_MEMORY, allocSize)) == NULL){
     return(E_UNEXPECTED);
   }
-  TRACE("SafeArray: %lu bytes allocated for descriptor.\n", allocSize);
+  TRACE("(%d): %lu bytes allocated for descriptor.\n", cDims, allocSize);
 
   return(S_OK);
 }
Index: dlls/oleaut32/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/tests/Makefile.in,v
retrieving revision 1.1
diff -u -u -r1.1 Makefile.in
--- dlls/oleaut32/tests/Makefile.in	9 Aug 2002 01:22:41 -0000	1.1
+++ dlls/oleaut32/tests/Makefile.in	20 Dec 2002 20:25:47 -0000
@@ -6,6 +6,7 @@
 IMPORTS   = oleaut32
 
 CTESTS = \
+	safearray.c \
 	vartest.c
 
 @MAKE_TEST_RULES@
/*
 * 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);

		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 %d, expected %d\n",i,(a?a->cbElements:0),vttypes[i]
		);
	}
}

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux