Many oleaut32 APIs are missing on Win95/IE3. Load them dynamically.

Uncomment some 'NULL' tests as they pass on Windows and on Wine.
Comment out those that crash on Win95 and indicate why they are
commented out.
Remove two redundant tests in vartest.c (VarI1FromBool and
VarUI2FromI2, last diff hunk).
This commit is contained in:
Francois Gouget 2003-01-07 19:40:40 +00:00 committed by Alexandre Julliard
parent 7c92869f86
commit 44eb8bf59f
2 changed files with 297 additions and 191 deletions

View File

@ -36,6 +36,12 @@
#include "wtypes.h" #include "wtypes.h"
#include "oleauto.h" #include "oleauto.h"
static HRESULT (WINAPI *pSafeArrayAllocDescriptorEx)(VARTYPE,UINT,struct tagSAFEARRAY**)=NULL;
static HRESULT (WINAPI *pSafeArrayCopyData)(struct tagSAFEARRAY*,struct tagSAFEARRAY*)=NULL;
static HRESULT (WINAPI *pSafeArrayGetIID)(struct tagSAFEARRAY*,GUID*)=NULL;
static HRESULT (WINAPI *pSafeArraySetIID)(struct tagSAFEARRAY*,REFGUID)=NULL;
static HRESULT (WINAPI *pSafeArrayGetVartype)(struct tagSAFEARRAY*,VARTYPE*)=NULL;
#define VARTYPE_NOT_SUPPORTED 0 #define VARTYPE_NOT_SUPPORTED 0
static struct { static struct {
VARTYPE vt; /* VT */ VARTYPE vt; /* VT */
@ -89,6 +95,7 @@ static struct {
START_TEST(safearray) START_TEST(safearray)
{ {
HMODULE hdll;
SAFEARRAY *a, b, *c; SAFEARRAY *a, b, *c;
unsigned int i; unsigned int i;
HRESULT hres; HRESULT hres;
@ -98,6 +105,13 @@ START_TEST(safearray)
IID iid; IID iid;
VARTYPE vt; VARTYPE vt;
hdll=LoadLibraryA("oleaut32.dll");
pSafeArrayAllocDescriptorEx=(void*)GetProcAddress(hdll,"SafeArrayAllocDescriptorEx");
pSafeArrayCopyData=(void*)GetProcAddress(hdll,"SafeArrayCopyData");
pSafeArrayGetIID=(void*)GetProcAddress(hdll,"SafeArrayGetIID");
pSafeArraySetIID=(void*)GetProcAddress(hdll,"SafeArraySetIID");
pSafeArrayGetVartype=(void*)GetProcAddress(hdll,"SafeArrayGetVartype");
hres = SafeArrayAllocDescriptor(0,&a); hres = SafeArrayAllocDescriptor(0,&a);
ok(E_INVALIDARG == hres,"SAAD(0) failed with hres %lx",hres); ok(E_INVALIDARG == hres,"SAAD(0) failed with hres %lx",hres);
@ -123,9 +137,7 @@ START_TEST(safearray)
hres=SafeArrayAllocDescriptor(65536,&a); hres=SafeArrayAllocDescriptor(65536,&a);
ok(E_INVALIDARG == hres,"SAAD(65536) failed with %lx",hres); ok(E_INVALIDARG == hres,"SAAD(65536) failed with %lx",hres);
hres=SafeArrayAllocDescriptor(1,NULL); /* Crashes on Win95: SafeArrayAllocDescriptor(xxx,NULL) */
ok(E_POINTER == hres,"SAAD(1,NULL) failed with %lx",hres);
bound.cElements = 1; bound.cElements = 1;
bound.lLbound = 0; bound.lLbound = 0;
@ -138,19 +150,27 @@ START_TEST(safearray)
((a != NULL) && (vttypes[i].elemsize == a->cbElements)), ((a != NULL) && (vttypes[i].elemsize == a->cbElements)),
"SAC(%d,1,[1,0]), result %ld, expected %d",vttypes[i].vt,(a?a->cbElements:0),vttypes[i].elemsize "SAC(%d,1,[1,0]), result %ld, expected %d",vttypes[i].vt,(a?a->cbElements:0),vttypes[i].elemsize
); );
if (a!=NULL) if (a!=NULL) {
ok(a->fFeatures == (vttypes[i].expflags | vttypes[i].addflags),"SAC of %d returned feature flags %x, expected %x", vttypes[i].vt, a->fFeatures, vttypes[i].expflags|vttypes[i].addflags); ok(a->fFeatures == (vttypes[i].expflags | vttypes[i].addflags),
ok(SafeArrayGetElemsize(a) == vttypes[i].elemsize,"SAGE for vt %d returned elemsize %d instead of expected %d",vttypes[i].vt, SafeArrayGetElemsize(a),vttypes[i].elemsize); "SAC of %d returned feature flags %x, expected %x",
vttypes[i].vt, a->fFeatures,
vttypes[i].expflags|vttypes[i].addflags);
ok(SafeArrayGetElemsize(a) == vttypes[i].elemsize,
"SAGE for vt %d returned elemsize %d instead of expected %d",
vttypes[i].vt, SafeArrayGetElemsize(a),vttypes[i].elemsize);
}
if (!a) continue; if (!a) continue;
hres = SafeArrayGetVartype(a, &vt); if (pSafeArrayGetVartype) {
hres = pSafeArrayGetVartype(a, &vt);
ok(hres == S_OK, "SAGVT of arra y with vt %d failed with %lx", vttypes[i].vt, hres); ok(hres == S_OK, "SAGVT of arra y with vt %d failed with %lx", vttypes[i].vt, hres);
if (vttypes[i].vt == VT_DISPATCH) { if (vttypes[i].vt == VT_DISPATCH) {
/* Special case. Checked against Windows. */ /* Special case. Checked against Windows. */
ok(vt == VT_UNKNOWN, "SAGVT of a rray with VT_DISPATCH returned not VT_UNKNOWN, but %d", vt); ok(vt == VT_UNKNOWN, "SAGVT of a rray with VT_DISPATCH returned not VT_UNKNOWN, but %d", vt);
} else { } else {
ok(vt == vttypes[i].vt, "SAGVT of array with vt %d returned %d", vttypes[i].vt, vt); ok(vt == vttypes[i].vt, "SAGVT of array with vt %d returned %d", vttypes[i].vt, vt);
}
} }
hres = SafeArrayCopy(a, &c); hres = SafeArrayCopy(a, &c);
@ -161,7 +181,8 @@ START_TEST(safearray)
ok(c->fFeatures == (vttypes[i].expflags | vttypes[i].addflags),"SAC of %d returned feature flags %x, expected %x", vttypes[i].vt, c->fFeatures, vttypes[i].expflags|vttypes[i].addflags); ok(c->fFeatures == (vttypes[i].expflags | vttypes[i].addflags),"SAC of %d returned feature flags %x, expected %x", vttypes[i].vt, c->fFeatures, vttypes[i].expflags|vttypes[i].addflags);
ok(SafeArrayGetElemsize(c) == vttypes[i].elemsize,"SAGE for vt %d returned elemsize %d instead of expected %d",vttypes[i].vt, SafeArrayGetElemsize(c),vttypes[i].elemsize); ok(SafeArrayGetElemsize(c) == vttypes[i].elemsize,"SAGE for vt %d returned elemsize %d instead of expected %d",vttypes[i].vt, SafeArrayGetElemsize(c),vttypes[i].elemsize);
hres = SafeArrayGetVartype(c, &vt); if (pSafeArrayGetVartype) {
hres = pSafeArrayGetVartype(c, &vt);
ok(hres == S_OK, "SAGVT of array with vt %d failed with %lx", vttypes[i].vt, hres); ok(hres == S_OK, "SAGVT of array with vt %d failed with %lx", vttypes[i].vt, hres);
if (vttypes[i].vt == VT_DISPATCH) { if (vttypes[i].vt == VT_DISPATCH) {
/* Special case. Checked against Windows. */ /* Special case. Checked against Windows. */
@ -169,11 +190,15 @@ START_TEST(safearray)
} else { } else {
ok(vt == vttypes[i].vt, "SAGVT of array with vt %d returned %d", vttypes[i].vt, vt); ok(vt == vttypes[i].vt, "SAGVT of array with vt %d returned %d", vttypes[i].vt, vt);
} }
hres = SafeArrayCopyData(a, c); }
if (pSafeArrayCopyData) {
hres = pSafeArrayCopyData(a, c);
ok(hres == S_OK, "failed to copy safearray data of vt %d with hres %lx", vttypes[i].vt, hres); ok(hres == S_OK, "failed to copy safearray data of vt %d with hres %lx", vttypes[i].vt, hres);
hres = SafeArrayDestroyData(c); hres = SafeArrayDestroyData(c);
ok(hres == S_OK,"SADD of copy of array with vt %d failed with hres %lx", vttypes[i].vt, hres); ok(hres == S_OK,"SADD of copy of array with vt %d failed with hres %lx", vttypes[i].vt, hres);
}
hres = SafeArrayDestroy(a); hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD of array with vt %d failed with hres %lx", vttypes[i].vt, hres); ok(hres == S_OK,"SAD of array with vt %d failed with hres %lx", vttypes[i].vt, hres);
@ -225,22 +250,27 @@ START_TEST(safearray)
/* IID functions */ /* IID functions */
/* init a small stack safearray */ /* init a small stack safearray */
if (pSafeArraySetIID) {
memset(&b, 0, sizeof(b)); memset(&b, 0, sizeof(b));
b.cDims = 1; b.cDims = 1;
memset(&iid, 0x42, sizeof(IID)); memset(&iid, 0x42, sizeof(IID));
hres = SafeArraySetIID(&b,&iid); hres = pSafeArraySetIID(&b,&iid);
ok(hres == E_INVALIDARG,"SafeArraySetIID of non IID capable safearray did not return E_INVALIDARG, but %lx",hres); ok(hres == E_INVALIDARG,"SafeArraySetIID of non IID capable safearray did not return E_INVALIDARG, but %lx",hres);
hres = SafeArrayAllocDescriptor(1,&a); hres = SafeArrayAllocDescriptor(1,&a);
ok((a->fFeatures & FADF_HAVEIID) == 0,"newly allocated descriptor with SAAD should not have FADF_HAVEIID"); ok((a->fFeatures & FADF_HAVEIID) == 0,"newly allocated descriptor with SAAD should not have FADF_HAVEIID");
hres = SafeArraySetIID(a,&iid); hres = pSafeArraySetIID(a,&iid);
ok(hres == E_INVALIDARG,"SafeArraySetIID of newly allocated descriptor with SAAD should return E_INVALIDARG, but %lx",hres); ok(hres == E_INVALIDARG,"SafeArraySetIID of newly allocated descriptor with SAAD should return E_INVALIDARG, but %lx",hres);
}
if (!pSafeArrayAllocDescriptorEx)
return;
for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) { for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) {
hres = SafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a); hres = pSafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a);
ok(a->fFeatures == vttypes[i].expflags,"SAADE(%d) resulted with flags %x, expected %x\n", vttypes[i].vt, a->fFeatures, vttypes[i].expflags); ok(a->fFeatures == vttypes[i].expflags,"SAADE(%d) resulted with flags %x, expected %x\n", vttypes[i].vt, a->fFeatures, vttypes[i].expflags);
if (a->fFeatures & FADF_HAVEIID) { if (a->fFeatures & FADF_HAVEIID) {
hres = SafeArrayGetIID(a, &iid); hres = pSafeArrayGetIID(a, &iid);
ok(hres == S_OK,"SAGIID failed for vt %d with hres %lx", vttypes[i].vt,hres); ok(hres == S_OK,"SAGIID failed for vt %d with hres %lx", vttypes[i].vt,hres);
switch (vttypes[i].vt) { switch (vttypes[i].vt) {
case VT_UNKNOWN: case VT_UNKNOWN:
@ -256,7 +286,7 @@ START_TEST(safearray)
break; break;
} }
} else { } else {
hres = SafeArrayGetIID(a, &iid); hres = pSafeArrayGetIID(a, &iid);
ok(hres == E_INVALIDARG,"SAGIID did not fail for vt %d with hres %lx", vttypes[i].vt,hres); ok(hres == E_INVALIDARG,"SAGIID did not fail for vt %d with hres %lx", vttypes[i].vt,hres);
} }
if (a->fFeatures & FADF_RECORD) { if (a->fFeatures & FADF_RECORD) {
@ -266,7 +296,7 @@ START_TEST(safearray)
ok(vttypes[i].vt == ((DWORD*)a)[-1], "FADF_HAVEVARTYPE set, but vt %d mismatch stored %ld",vttypes[i].vt,((DWORD*)a)[-1]); ok(vttypes[i].vt == ((DWORD*)a)[-1], "FADF_HAVEVARTYPE set, but vt %d mismatch stored %ld",vttypes[i].vt,((DWORD*)a)[-1]);
} }
hres = SafeArrayGetVartype(a, &vt); hres = pSafeArrayGetVartype(a, &vt);
ok(hres == S_OK, "SAGVT of array with vt %d failed with %lx", vttypes[i].vt, hres); ok(hres == S_OK, "SAGVT of array with vt %d failed with %lx", vttypes[i].vt, hres);
if (vttypes[i].vt == VT_DISPATCH) { if (vttypes[i].vt == VT_DISPATCH) {
@ -277,13 +307,13 @@ START_TEST(safearray)
} }
if (a->fFeatures & FADF_HAVEIID) { if (a->fFeatures & FADF_HAVEIID) {
hres = SafeArraySetIID(a, &IID_IStorage); /* random IID */ hres = pSafeArraySetIID(a, &IID_IStorage); /* random IID */
ok(hres == S_OK,"SASIID failed with FADF_HAVEIID set for vt %d with %lx", vttypes[i].vt, hres); ok(hres == S_OK,"SASIID failed with FADF_HAVEIID set for vt %d with %lx", vttypes[i].vt, hres);
hres = SafeArrayGetIID(a, &iid); hres = pSafeArrayGetIID(a, &iid);
ok(hres == S_OK,"SAGIID failed with FADF_HAVEIID set for vt %d with %lx", vttypes[i].vt, hres); ok(hres == S_OK,"SAGIID failed with FADF_HAVEIID set for vt %d with %lx", vttypes[i].vt, hres);
ok(IsEqualGUID(&iid, &IID_IStorage),"returned iid is not IID_IStorage"); ok(IsEqualGUID(&iid, &IID_IStorage),"returned iid is not IID_IStorage");
} else { } else {
hres = SafeArraySetIID(a, &IID_IStorage); /* random IID */ hres = pSafeArraySetIID(a, &IID_IStorage); /* random IID */
ok(hres == E_INVALIDARG,"SASIID did not failed with !FADF_HAVEIID set for vt %d with %lx", vttypes[i].vt, hres); ok(hres == E_INVALIDARG,"SASIID did not failed with !FADF_HAVEIID set for vt %d with %lx", vttypes[i].vt, hres);
} }
hres = SafeArrayDestroyDescriptor(a); hres = SafeArrayDestroyDescriptor(a);

View File

@ -75,6 +75,30 @@
#include "oleauto.h" #include "oleauto.h"
static HRESULT (WINAPI *pVarBstrFromI1)(CHAR,LCID,ULONG,BSTR*)=NULL;
static HRESULT (WINAPI *pVarI1FromBool)(VARIANT_BOOL,CHAR*)=NULL;
static HRESULT (WINAPI *pVarI1FromDate)(DATE,CHAR*)=NULL;
static HRESULT (WINAPI *pVarI1FromI4)(LONG,CHAR*)=NULL;
static HRESULT (WINAPI *pVarI1FromR8)(double,CHAR*)=NULL;
static HRESULT (WINAPI *pVarI1FromStr)(OLECHAR*,LCID,ULONG,CHAR*);
static HRESULT (WINAPI *pVarI1FromUI1)(BYTE,CHAR*)=NULL;
static HRESULT (WINAPI *pVarI2FromUI2)(USHORT,short*)=NULL;
static HRESULT (WINAPI *pVarUI2FromBool)(VARIANT_BOOL,USHORT*)=NULL;
static HRESULT (WINAPI *pVarUI2FromDate)(DATE,USHORT*)=NULL;
static HRESULT (WINAPI *pVarUI2FromI2)(short,USHORT*)=NULL;
static HRESULT (WINAPI *pVarUI2FromI4)(LONG,USHORT*);
static HRESULT (WINAPI *pVarUI2FromR8)(double,USHORT*)=NULL;
static HRESULT (WINAPI *pVarUI2FromStr)(OLECHAR*,LCID,ULONG,USHORT*)=NULL;
static HRESULT (WINAPI *pVarUI4FromBool)(VARIANT_BOOL,ULONG*)=NULL;
static HRESULT (WINAPI *pVarUI4FromDate)(DATE,ULONG*)=NULL;
static HRESULT (WINAPI *pVarUI4FromI2)(short,ULONG*)=NULL;
static HRESULT (WINAPI *pVarUI4FromR8)(double,ULONG*)=NULL;
static HRESULT (WINAPI *pVarUI4FromStr)(OLECHAR*,LCID,ULONG,ULONG*)=NULL;
#define MAX_BUFFER 1024 #define MAX_BUFFER 1024
static char* WtoA( OLECHAR* p ) static char* WtoA( OLECHAR* p )
@ -1662,6 +1686,7 @@ static const struct _strret_U4 {
START_TEST(vartest) START_TEST(vartest)
{ {
HMODULE hdll;
VARIANTARG va; VARIANTARG va;
VARIANTARG vb; VARIANTARG vb;
VARIANTARG vc; VARIANTARG vc;
@ -1700,7 +1725,28 @@ START_TEST(vartest)
/* Start testing the Low-Level API ( the coercions ) /* Start testing the Low-Level API ( the coercions )
*/ */
hdll=LoadLibraryA("netapi32.dll");
pVarI1FromBool=(void*)GetProcAddress(hdll,"VarI1FromBool");
pVarI1FromDate=(void*)GetProcAddress(hdll,"VarI1FromDate");
pVarI1FromI4=(void*)GetProcAddress(hdll,"VarI1FromI4");
pVarI1FromR8=(void*)GetProcAddress(hdll,"VarI1FromR8");
pVarI1FromStr=(void*)GetProcAddress(hdll,"VarI1FromStr");
pVarI1FromUI1=(void*)GetProcAddress(hdll,"VarI1FromUI1");
pVarI2FromUI2=(void*)GetProcAddress(hdll,"VarI2FromUI2");
pVarUI2FromBool=(void*)GetProcAddress(hdll,"VarUI2FromBool");
pVarUI2FromDate=(void*)GetProcAddress(hdll,"VarUI2FromDate");
pVarUI2FromI2=(void*)GetProcAddress(hdll,"VarUI2FromI2");
pVarUI2FromI4=(void*)GetProcAddress(hdll,"VarUI2FromI4");
pVarUI2FromR8=(void*)GetProcAddress(hdll,"VarUI2FromR8");
pVarUI2FromStr=(void*)GetProcAddress(hdll,"VarUI2FromStr");
pVarUI4FromBool=(void*)GetProcAddress(hdll,"VarUI4FromBool");
pVarUI4FromDate=(void*)GetProcAddress(hdll,"VarUI4FromDate");
pVarUI4FromI2=(void*)GetProcAddress(hdll,"VarUI4FromI2");
pVarUI4FromR8=(void*)GetProcAddress(hdll,"VarUI4FromR8");
pVarUI4FromStr=(void*)GetProcAddress(hdll,"VarUI4FromStr");
/* unsigned char from... /* unsigned char from...
*/ */
@ -1708,9 +1754,7 @@ START_TEST(vartest)
#define XOK "should return S_OK" #define XOK "should return S_OK"
#define XOV "should return DISP_E_OVERFLOW" #define XOV "should return DISP_E_OVERFLOW"
/* ok(S_OK == VarUI1FromI2( 0, NULL ), XOK); /* Crashes on Win95: VarUI1FromI2( 0, NULL ) */
*/
trace( "VarUI1FromI2: passing in NULL as return val makes it crash, need to write proper test.\n" );
ok(VarUI1FromStr(NULL,0,0,pByte) == DISP_E_TYPEMISMATCH,"should return DISP_E_TYPEMISMATCH"); ok(VarUI1FromStr(NULL,0,0,pByte) == DISP_E_TYPEMISMATCH,"should return DISP_E_TYPEMISMATCH");
ok(S_OK == VarUI1FromI2( 0, pByte ), XOK); ok(S_OK == VarUI1FromI2( 0, pByte ), XOK);
@ -1796,68 +1840,78 @@ START_TEST(vartest)
/* unsigned short from ... */ /* unsigned short from ... */
trace( "\n\n======== Testing VarUI2FromXXX ========\n"); trace( "\n\n======== Testing VarUI2FromXXX ========\n");
ok(DISP_E_OVERFLOW == VarUI2FromI2( -1, pUShort ), XOV); if (pVarUI2FromI2) {
/* ok(S_OK == VarUI2FromI2( 0, NULL ), XOK); ok(DISP_E_OVERFLOW == pVarUI2FromI2( -1, pUShort ), XOV);
*/ ok(S_OK == pVarUI2FromI2( 0, NULL ), XOK);
trace("VarUI2FromI2: passing in NULL as return val makes it crash, needs to be fixed.\n");
ok(DISP_E_TYPEMISMATCH == VarUI2FromStr( NULL, 0, 0, pUShort ), "should return DISP_E_TYPEMISMATCH"); ok(S_OK == pVarUI2FromI2( 0, pUShort ), XOK);
ok(S_OK == VarUI2FromI2( 0, pUShort ), XOK);
ok(*pUShort == 0,"0 should be 0"); ok(*pUShort == 0,"0 should be 0");
ok(S_OK == VarUI2FromI2( 69, pUShort ), XOK); ok(S_OK == pVarUI2FromI2( 69, pUShort ), XOK);
ok(*pUShort == 69,"69 should be 69"); ok(*pUShort == 69,"69 should be 69");
ok(S_OK == VarUI2FromI2( 70, pUShort ), XOK); ok(S_OK == pVarUI2FromI2( 70, pUShort ), XOK);
ok(*pUShort == 70,"70 should be 70"); ok(*pUShort == 70,"70 should be 70");
ok(S_OK == VarUI2FromI2( 128, pUShort ), XOK); ok(S_OK == pVarUI2FromI2( 128, pUShort ), XOK);
ok(*pUShort == 128,"128 should be 128"); ok(*pUShort == 128,"128 should be 128");
}
ok(S_OK == VarUI2FromI4( 65535, pUShort ), XOK); if (pVarUI2FromI4) {
ok(S_OK == pVarUI2FromI4( 65535, pUShort ), XOK);
ok(*pUShort == 65535,"65535 should be 65535"); ok(*pUShort == 65535,"65535 should be 65535");
ok(DISP_E_OVERFLOW == VarUI2FromI4( 65536, pUShort ), XOV); ok(DISP_E_OVERFLOW == pVarUI2FromI4( 65536, pUShort ), XOV);
ok(DISP_E_OVERFLOW == VarUI2FromI4( 65537, pUShort ), XOV); ok(DISP_E_OVERFLOW == pVarUI2FromI4( 65537, pUShort ), XOV);
ok(S_OK == VarUI2FromR8( 0.0, pUShort ), XOK); }
if (pVarUI2FromR8) {
ok(S_OK == pVarUI2FromR8( 0.0, pUShort ), XOK);
ok(*pUShort == 0,"0.0 should be 0"); ok(*pUShort == 0,"0.0 should be 0");
ok(S_OK == VarUI2FromR8( 69.33, pUShort ), XOK); ok(S_OK == pVarUI2FromR8( 69.33, pUShort ), XOK);
ok(*pUShort == 69,"69.33 should be 69"); ok(*pUShort == 69,"69.33 should be 69");
ok(S_OK == VarUI2FromR8( 69.66, pUShort ), XOK); ok(S_OK == pVarUI2FromR8( 69.66, pUShort ), XOK);
ok(*pUShort == 70,"69.66 should be 70"); ok(*pUShort == 70,"69.66 should be 70");
ok(DISP_E_OVERFLOW == VarUI2FromR8( -69.33, pUShort ), XOV); ok(DISP_E_OVERFLOW == pVarUI2FromR8( -69.33, pUShort ), XOV);
ok(DISP_E_OVERFLOW == VarUI2FromR8( -69.66, pUShort ), XOV); ok(DISP_E_OVERFLOW == pVarUI2FromR8( -69.66, pUShort ), XOV);
ok(S_OK == VarUI2FromR8( -0.5, pUShort ), XOK); ok(S_OK == pVarUI2FromR8( -0.5, pUShort ), XOK);
ok(*pUShort == 0, "-0.5 -> 0"); ok(*pUShort == 0, "-0.5 -> 0");
ok(DISP_E_OVERFLOW == VarUI2FromR8( -0.51, pUShort ), XOV); ok(DISP_E_OVERFLOW == pVarUI2FromR8( -0.51, pUShort ), XOV);
ok(S_OK == VarUI2FromR8( -0.49, pUShort ), XOK); ok(S_OK == pVarUI2FromR8( -0.49, pUShort ), XOK);
ok(*pUShort == 0, "-0.49 -> 0"); ok(*pUShort == 0, "-0.49 -> 0");
ok(S_OK == VarUI2FromR8( 0.5, pUShort ), XOK); ok(S_OK == pVarUI2FromR8( 0.5, pUShort ), XOK);
ok(*pUShort == 0,"0.5 should be 0"); ok(*pUShort == 0,"0.5 should be 0");
ok(S_OK == VarUI2FromR8( 0.51, pUShort ), XOK); ok(S_OK == pVarUI2FromR8( 0.51, pUShort ), XOK);
ok(*pUShort == 1,"0.51 should be 1"); ok(*pUShort == 1,"0.51 should be 1");
ok(S_OK == VarUI2FromR8( 0.49, pUShort ), XOK); ok(S_OK == pVarUI2FromR8( 0.49, pUShort ), XOK);
ok(*pUShort == 0,"0.49 should be 0"); ok(*pUShort == 0,"0.49 should be 0");
}
ok(S_OK == VarUI2FromDate( 0.0, pUShort ), XOK); if (pVarUI2FromDate) {
ok(S_OK == pVarUI2FromDate( 0.0, pUShort ), XOK);
ok(*pUShort == 0,"0.0 should be 0"); ok(*pUShort == 0,"0.0 should be 0");
ok(S_OK == VarUI2FromDate( 69.33, pUShort ), XOK); ok(S_OK == pVarUI2FromDate( 69.33, pUShort ), XOK);
ok(*pUShort == 69,"69.33 should be 69"); ok(*pUShort == 69,"69.33 should be 69");
ok(S_OK == VarUI2FromDate( 69.66, pUShort ), XOK); ok(S_OK == pVarUI2FromDate( 69.66, pUShort ), XOK);
ok(*pUShort == 70,"69.66 should be 70"); ok(*pUShort == 70,"69.66 should be 70");
ok(DISP_E_OVERFLOW == VarUI2FromDate( -69.33, pUShort ), XOV); ok(DISP_E_OVERFLOW == pVarUI2FromDate( -69.33, pUShort ), XOV);
ok(DISP_E_OVERFLOW == VarUI2FromDate( -69.66, pUShort ), XOV); ok(DISP_E_OVERFLOW == pVarUI2FromDate( -69.66, pUShort ), XOV);
}
ok(S_OK == VarUI2FromBool( VARIANT_TRUE, pUShort ), XOK); if (pVarUI2FromBool) {
ok(S_OK == pVarUI2FromBool( VARIANT_TRUE, pUShort ), XOK);
ok(*pUShort == 65535,"TRUE should be 65535"); ok(*pUShort == 65535,"TRUE should be 65535");
ok(S_OK == VarUI2FromBool( VARIANT_FALSE, pUShort ), XOK); ok(S_OK == pVarUI2FromBool( VARIANT_FALSE, pUShort ), XOK);
ok(*pUShort == 0,"FALSE should be 0"); ok(*pUShort == 0,"FALSE should be 0");
}
if (pVarUI2FromStr) {
ok(DISP_E_TYPEMISMATCH == pVarUI2FromStr( NULL, 0, 0, pUShort ), "should return DISP_E_TYPEMISMATCH");
for (i = 0; i < NB_OLE_STRINGS; i++) for (i = 0; i < NB_OLE_STRINGS; i++)
{ {
*pUShort=42; *pUShort=42;
rc=VarUI2FromStr( pOleChar[i], 0, 0, pUShort ); rc=pVarUI2FromStr( pOleChar[i], 0, 0, pUShort );
ok(rc == strrets_U2[i].error, ok(rc == strrets_U2[i].error,
"VarUI2FromStr([%d]=\"%s\") rc=%lx instead of %lx", "VarUI2FromStr([%d]=\"%s\") rc=%lx instead of %lx",
i,_pTestStrA[i],rc,strrets_U2[i].error); i,_pTestStrA[i],rc,strrets_U2[i].error);
@ -1867,75 +1921,83 @@ START_TEST(vartest)
i,_pTestStrA[i],*pUShort,strrets_U2[i].retval); i,_pTestStrA[i],*pUShort,strrets_U2[i].retval);
} }
} }
}
/* unsigned long from ... /* unsigned long from ...
*/ */
trace( "\n\n======== Testing VarUI4FromXXX ========\n"); trace( "\n\n======== Testing VarUI4FromXXX ========\n");
/*ok(S_OK == VarUI4FromI2( 0, NULL ), XOK);
*/
trace( "VarUI4FromI2: passing in NULL as return val makes it crash, implement me.\n");
ok(DISP_E_TYPEMISMATCH == VarUI4FromStr( NULL, 0, 0, pULong ), "should erturn DISP_E_TYPEMISMATCH"); if (pVarUI4FromI2) {
ok(S_OK == pVarUI4FromI2( 0, NULL ), XOK);
ok(S_OK == VarUI4FromI2( 0, pULong ), XOK); ok(S_OK == pVarUI4FromI2( 0, pULong ), XOK);
ok(*pULong == 0,"0 should be 0"); ok(*pULong == 0,"0 should be 0");
ok(S_OK == VarUI4FromI2( 69, pULong ), XOK); ok(S_OK == pVarUI4FromI2( 69, pULong ), XOK);
ok(*pULong == 69,"69 should be 69"); ok(*pULong == 69,"69 should be 69");
ok(S_OK == VarUI4FromI2( 70, pULong ), XOK); ok(S_OK == pVarUI4FromI2( 70, pULong ), XOK);
ok(*pULong == 70,"70 should be 70"); ok(*pULong == 70,"70 should be 70");
ok(S_OK == VarUI4FromI2( 128, pULong ), XOK); ok(S_OK == pVarUI4FromI2( 128, pULong ), XOK);
ok(*pULong == 128,"128 should be 128"); ok(*pULong == 128,"128 should be 128");
ok(S_OK == VarUI4FromI2( 255, pULong ), XOK); ok(S_OK == pVarUI4FromI2( 255, pULong ), XOK);
ok(*pULong == 255,"255 should be 255"); ok(*pULong == 255,"255 should be 255");
}
ok(S_OK == VarUI4FromR8( 4294967295.0, pULong ), XOK); if (pVarUI4FromR8) {
ok(S_OK == pVarUI4FromR8( 4294967295.0, pULong ), XOK);
ok(*pULong == 4294967295U,"4294967295.0 should be 4294967295"); ok(*pULong == 4294967295U,"4294967295.0 should be 4294967295");
ok(DISP_E_OVERFLOW == VarUI4FromR8( 4294967296.0, pULong ), XOV); ok(DISP_E_OVERFLOW == pVarUI4FromR8( 4294967296.0, pULong ), XOV);
ok(S_OK == VarUI4FromR8( 0.0, pULong ), XOK); ok(S_OK == pVarUI4FromR8( 0.0, pULong ), XOK);
ok(*pULong == 0,"0 should be 0"); ok(*pULong == 0,"0 should be 0");
ok(S_OK == VarUI4FromR8( 69.33, pULong ), XOK); ok(S_OK == pVarUI4FromR8( 69.33, pULong ), XOK);
ok(*pULong == 69,"69.33 should be 69"); ok(*pULong == 69,"69.33 should be 69");
ok(S_OK == VarUI4FromR8( 69.66, pULong ), XOK); ok(S_OK == pVarUI4FromR8( 69.66, pULong ), XOK);
ok(*pULong == 70,"69.66 should be 70"); ok(*pULong == 70,"69.66 should be 70");
ok(DISP_E_OVERFLOW == VarUI4FromR8( -69.33, pULong ), XOV); ok(DISP_E_OVERFLOW == pVarUI4FromR8( -69.33, pULong ), XOV);
ok(DISP_E_OVERFLOW == VarUI4FromR8( -69.66, pULong ), XOV); ok(DISP_E_OVERFLOW == pVarUI4FromR8( -69.66, pULong ), XOV);
ok(S_OK == VarUI4FromR8( -0.5, pULong ), XOK); ok(S_OK == pVarUI4FromR8( -0.5, pULong ), XOK);
ok(*pULong == 0,"-0.5 should be 0"); ok(*pULong == 0,"-0.5 should be 0");
ok(DISP_E_OVERFLOW == VarUI4FromR8( -0.51, pULong ), XOV); ok(DISP_E_OVERFLOW == pVarUI4FromR8( -0.51, pULong ), XOV);
ok(S_OK == VarUI4FromR8( -0.49, pULong ), XOK); ok(S_OK == pVarUI4FromR8( -0.49, pULong ), XOK);
ok(*pULong == 0,"-0.49 should be 0"); ok(*pULong == 0,"-0.49 should be 0");
ok(S_OK == VarUI4FromR8( 0.5, pULong ), XOK); ok(S_OK == pVarUI4FromR8( 0.5, pULong ), XOK);
ok(*pULong == 0,"0.5 should be 0"); ok(*pULong == 0,"0.5 should be 0");
ok(S_OK == VarUI4FromR8( 0.51, pULong ), XOK); ok(S_OK == pVarUI4FromR8( 0.51, pULong ), XOK);
ok(*pULong == 1,"0.51 should be 1"); ok(*pULong == 1,"0.51 should be 1");
ok(S_OK == VarUI4FromR8( 0.49, pULong ), XOK); ok(S_OK == pVarUI4FromR8( 0.49, pULong ), XOK);
ok(*pULong == 0,"0.49 should be 0"); ok(*pULong == 0,"0.49 should be 0");
}
ok(S_OK == VarUI4FromDate( 0.0, pULong ), XOK); if (pVarUI4FromDate) {
ok(S_OK == pVarUI4FromDate( 0.0, pULong ), XOK);
ok(*pULong == 0,"0.0 should be 0"); ok(*pULong == 0,"0.0 should be 0");
ok(S_OK == VarUI4FromDate( 69.33, pULong ), XOK); ok(S_OK == pVarUI4FromDate( 69.33, pULong ), XOK);
ok(*pULong == 69,"69.33 should be 69"); ok(*pULong == 69,"69.33 should be 69");
ok(S_OK == VarUI4FromDate( 69.66, pULong ), XOK); ok(S_OK == pVarUI4FromDate( 69.66, pULong ), XOK);
ok(*pULong == 70,"69.66 should be 70"); ok(*pULong == 70,"69.66 should be 70");
ok(DISP_E_OVERFLOW == VarUI4FromDate( -69.33, pULong ), XOV); ok(DISP_E_OVERFLOW == pVarUI4FromDate( -69.33, pULong ), XOV);
ok(DISP_E_OVERFLOW == VarUI4FromDate( -69.66, pULong ), XOV); ok(DISP_E_OVERFLOW == pVarUI4FromDate( -69.66, pULong ), XOV);
}
ok(S_OK == VarUI4FromBool( VARIANT_TRUE, pULong ), XOK); if (pVarUI4FromBool) {
ok(S_OK == pVarUI4FromBool( VARIANT_TRUE, pULong ), XOK);
ok(*pULong == 4294967295U, "TRUE should be 4294967295"); ok(*pULong == 4294967295U, "TRUE should be 4294967295");
ok(S_OK == VarUI4FromBool( VARIANT_FALSE, pULong ), XOK); ok(S_OK == pVarUI4FromBool( VARIANT_FALSE, pULong ), XOK);
ok(*pULong == 0, "FALSE should be 0"); ok(*pULong == 0, "FALSE should be 0");
}
if (pVarUI4FromStr) {
ok(DISP_E_TYPEMISMATCH == pVarUI4FromStr( NULL, 0, 0, pULong ), "should erturn DISP_E_TYPEMISMATCH");
for (i = 0; i < NB_OLE_STRINGS; i++) for (i = 0; i < NB_OLE_STRINGS; i++)
{ {
*pULong=42; *pULong=42;
rc=VarUI4FromStr( pOleChar[i], 0, 0, pULong ); rc=pVarUI4FromStr( pOleChar[i], 0, 0, pULong );
ok(rc == strrets_U4[i].error, ok(rc == strrets_U4[i].error,
"VarUI4FromStr([%d]=\"%s\") rc=%lx instead of %lx", "VarUI4FromStr([%d]=\"%s\") rc=%lx instead of %lx",
i,_pTestStrA[i],rc,strrets_U4[i].error); i,_pTestStrA[i],rc,strrets_U4[i].error);
@ -1945,50 +2007,63 @@ START_TEST(vartest)
i,_pTestStrA[i],*pULong,strrets_U4[i].retval); i,_pTestStrA[i],*pULong,strrets_U4[i].retval);
} }
} }
}
/* CHAR from ... /* CHAR from ...
*/ */
trace( "\n\n======== Testing VarI1FromXXX ========\n"); trace( "\n\n======== Testing VarI1FromXXX ========\n");
ok(S_OK == VarI1FromBool( VARIANT_TRUE, pByte ), XOK); if (pVarI1FromBool) {
ok(*pByte == 255, " TRUE should be 255"); ok(S_OK == pVarI1FromBool( VARIANT_TRUE, pByte ), XOK);
ok(*pByte == 0xff,"true should be 0xff");
ok(S_OK == VarI1FromBool( VARIANT_TRUE, pChar ), XOK); ok(S_OK == pVarI1FromBool( VARIANT_TRUE, pChar ), XOK);
ok(*pChar == -1, "TRUE should be -1"); ok(*pChar == -1, "TRUE should be -1");
ok(S_OK == VarI1FromBool( VARIANT_FALSE, pChar ), XOK); ok(S_OK == pVarI1FromBool( VARIANT_FALSE, pChar ), XOK);
ok(*pChar == 0, "FALSE should be 0"); ok(*pChar == 0, "FALSE should be 0");
}
ok(DISP_E_OVERFLOW == VarI1FromUI1( (unsigned char)32767, pChar ), XOV); if (pVarI1FromUI1) {
ok(DISP_E_OVERFLOW == pVarI1FromUI1( (unsigned char)32767, pChar ), XOV);
ok(*pChar == 0, "should still be 0"); ok(*pChar == 0, "should still be 0");
ok(DISP_E_OVERFLOW == VarI1FromUI1( (unsigned char)65535, pChar ), XOV); ok(DISP_E_OVERFLOW == pVarI1FromUI1( (unsigned char)65535, pChar ), XOV);
ok(*pChar == 0, "should still be 0"); ok(*pChar == 0, "should still be 0");
}
ok(DISP_E_OVERFLOW == VarI1FromI4( 32767, pChar ), XOV); if (pVarI1FromI4) {
ok(DISP_E_OVERFLOW == pVarI1FromI4( 32767, pChar ), XOV);
ok(*pChar == 0, "should still be 0"); ok(*pChar == 0, "should still be 0");
ok(DISP_E_OVERFLOW == VarI1FromI4( 32768, pChar ), XOV); ok(DISP_E_OVERFLOW == pVarI1FromI4( 32768, pChar ), XOV);
ok(*pChar == 0, "should still be 0"); ok(*pChar == 0, "should still be 0");
ok(DISP_E_OVERFLOW == VarI1FromI4( -32768, pChar ), XOV); ok(DISP_E_OVERFLOW == pVarI1FromI4( -32768, pChar ), XOV);
ok(*pChar == 0, "should still be 0"); ok(*pChar == 0, "should still be 0");
ok(DISP_E_OVERFLOW == VarI1FromI4( -32769, pChar ), XOV); ok(DISP_E_OVERFLOW == pVarI1FromI4( -32769, pChar ), XOV);
ok(*pChar == 0, "should still be 0"); ok(*pChar == 0, "should still be 0");
}
ok(S_OK == VarI1FromR8( 69.33, pChar ), XOK); if (pVarI1FromR8) {
ok(S_OK == pVarI1FromR8( 69.33, pChar ), XOK);
ok(*pChar == 69, "69.33 should be 69"); ok(*pChar == 69, "69.33 should be 69");
ok(S_OK == VarI1FromR8( 69.66, pChar ), XOK); ok(S_OK == pVarI1FromR8( 69.66, pChar ), XOK);
ok(*pChar == 70, "69.66 should be 70"); ok(*pChar == 70, "69.66 should be 70");
ok(S_OK == VarI1FromR8( -69.33, pChar ), XOK); ok(S_OK == pVarI1FromR8( -69.33, pChar ), XOK);
ok(*pChar == -69, "-69.33 should be -69"); ok(*pChar == -69, "-69.33 should be -69");
ok(S_OK == VarI1FromR8( -69.66, pChar ), XOK); ok(S_OK == pVarI1FromR8( -69.66, pChar ), XOK);
ok(*pChar == -70, "-69.66 should be -70");
ok(S_OK == VarI1FromDate( -69.66, pChar ), XOK);
ok(*pChar == -70, "-69.66 should be -70"); ok(*pChar == -70, "-69.66 should be -70");
}
if (pVarI1FromDate) {
ok(S_OK == pVarI1FromDate( -69.66, pChar ), XOK);
ok(*pChar == -70, "-69.66 should be -70");
}
if (pVarI1FromStr) {
for (i = 0; i < NB_OLE_STRINGS; i++) for (i = 0; i < NB_OLE_STRINGS; i++)
{ {
*pChar=42; *pChar=42;
rc=VarI1FromStr( pOleChar[i], 0, 0, pChar ); rc=pVarI1FromStr( pOleChar[i], 0, 0, pChar );
ok(rc == strrets_I1[i].error, ok(rc == strrets_I1[i].error,
"VarI1FromStr([%d]=\"%s\") rc=%lx instead of %lx", "VarI1FromStr([%d]=\"%s\") rc=%lx instead of %lx",
i,_pTestStrA[i],rc,strrets_I1[i].error); i,_pTestStrA[i],rc,strrets_I1[i].error);
@ -1998,15 +2073,18 @@ START_TEST(vartest)
i,_pTestStrA[i],*pChar,strrets_I1[i].retval); i,_pTestStrA[i],*pChar,strrets_I1[i].retval);
} }
} }
}
/* short from ... /* short from ...
*/ */
trace( "\n\n======== Testing VarI2FromXXX ========\n"); trace( "\n\n======== Testing VarI2FromXXX ========\n");
ok(S_OK == VarI2FromUI2( 32767, pShort ), XOK); if (pVarI2FromUI2) {
ok(S_OK == pVarI2FromUI2( 32767, pShort ), XOK);
ok(*pShort == 32767, "should be 32767"); ok(*pShort == 32767, "should be 32767");
ok(DISP_E_OVERFLOW == VarI2FromUI2( 65535, pShort ), XOV); ok(DISP_E_OVERFLOW == pVarI2FromUI2( 65535, pShort ), XOV);
ok(*pShort == 32767, "pShort should be unchanged"); ok(*pShort == 32767, "pShort should be unchanged");
}
ok(S_OK == VarI2FromI4( 32767, pShort ), XOK); ok(S_OK == VarI2FromI4( 32767, pShort ), XOK);
ok(*pShort == 32767, "should be 32767"); ok(*pShort == 32767, "should be 32767");
@ -2274,18 +2352,16 @@ START_TEST(vartest)
} }
} }
ok(S_OK == VarI1FromBool( VARIANT_TRUE, pByte ), XOK);
ok(*pByte == 0xff,"true should be 0xff");
ok(DISP_E_OVERFLOW == VarUI2FromI2( -1, pUShort ), XOV);
/* BSTR from ... /* BSTR from ...
*/ */
trace( "\n\n======== Testing VarBSTRFromXXX ========\n"); trace( "\n\n======== Testing VarBSTRFromXXX ========\n");
/* integers... /* integers...
*/ */
ok(S_OK == VarBstrFromI1( -100, 0, 0, &bstr ), XOK); if (pVarBstrFromI1) {
ok(S_OK == pVarBstrFromI1( -100, 0, 0, &bstr ), XOK);
ok(!strcmp(WtoA(bstr),"\"-100\""),"should be string -100"); ok(!strcmp(WtoA(bstr),"\"-100\""),"should be string -100");
}
ok(S_OK == VarBstrFromUI1( 0x5A, 0, 0, &bstr ), XOK); ok(S_OK == VarBstrFromUI1( 0x5A, 0, 0, &bstr ), XOK);
ok(!strcmp(WtoA(bstr),"\"90\""),"should be string 90"); ok(!strcmp(WtoA(bstr),"\"90\""),"should be string 90");