oleaut: Merge the VarCmp tests from vartype.c into vartest.c.

This commit is contained in:
Michael Stefaniuc 2006-01-18 11:30:01 +01:00 committed by Alexandre Julliard
parent 68b9225022
commit 0d00d9af0e
2 changed files with 21 additions and 67 deletions

View File

@ -4946,6 +4946,9 @@ static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
_VARCMP(vt1,val1,VT_RESERVED,vt2,val2,VT_RESERVED,lcid,0,res4)
#define VARCMP(vt1,val1,vt2,val2,result) \
VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
/* The above macros do not work for VT_NULL as NULL gets expanded first */
#define V_NULL_ V_NULL
#define VT_NULL_ VT_NULL
static void test_VarCmp(void)
{
@ -5081,8 +5084,14 @@ static void test_VarCmp(void)
ok(V_EMPTY(&left) == 19, "VT_EMPTY modified!\n");
ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
VARCMP(I4,1,UI1,1,VARCMP_EQ);
VARCMP(I2,2,I2,2,VARCMP_EQ);
VARCMP(I2,1,I2,2,VARCMP_LT);
VARCMP(I2,2,I2,1,VARCMP_GT);
VARCMP(I2,2,EMPTY,1,VARCMP_GT);
VARCMP(I2,2,NULL_,1,VARCMP_NULL);
/* BSTR handling, especialy in conjunction with VT_RESERVED */
VARCMP(BSTR,bstr0,NULL_,0,VARCMP_NULL);
VARCMP(BSTR,bstr0,BSTR,bstr0,VARCMP_EQ);
VARCMP(BSTR,bstrempty,BSTR,bstr0,VARCMP_LT);
VARCMP(BSTR,bstr7,BSTR,bstr0,VARCMP_GT);
@ -5091,14 +5100,17 @@ static void test_VarCmp(void)
VARCMP(BSTR,NULL,BSTR,NULL,VARCMP_EQ);
VARCMP(BSTR,bstrempty,BSTR,NULL,VARCMP_EQ);
VARCMP(BSTR,NULL,EMPTY,0,VARCMP_EQ);
VARCMP(EMPTY,0,BSTR,NULL,VARCMP_EQ);
VARCMP(EMPTY,0,BSTR,bstrempty,VARCMP_EQ);
VARCMP(EMPTY,1,BSTR,bstrempty,VARCMP_EQ);
VARCMP(BSTR,bstr0,EMPTY,0,VARCMP_GT);
VARCMP(BSTR,bstr42,EMPTY,0,VARCMP_GT);
VARCMPEX(BSTR,bstrempty,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
VARCMPEX(BSTR,bstrempty,I2,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
VARCMPEX(I4,0,BSTR,bstrempty,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
VARCMPEX(BSTR,NULL,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
VARCMPEX(I4,7,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
_VARCMP(BSTR,(BSTR)100,0,I2,100,0,lcid,0,VARCMP_GT);
VARCMPEX(BSTR,bstr0,UI1,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
VARCMPEX(I2,0,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
@ -5107,6 +5119,7 @@ static void test_VarCmp(void)
VARCMPEX(BSTR,bstr2cents,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
VARCMP(BSTR,bstr2cents,I4,-1,VARCMP_GT);
VARCMPEX(BSTR,bstr2cents,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
VARCMPEX(BSTR,bstr0,I2,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
VARCMPEX(BSTR,bstr0,I4,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
VARCMPEX(BSTR,bstr0,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
VARCMP(BSTR,bstr1,I4,0,VARCMP_GT);
@ -5131,6 +5144,9 @@ static void test_VarCmp(void)
VARCMPEX(BSTR,bstr666neg,I4,-666,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
VARCMPEX(BSTR,bstr7,R8,7.0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
VARCMPEX(R8,3.141592,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
VARCMP(BSTR,bstr7,BSTR,bstr7,VARCMP_EQ);
VARCMP(BSTR,bstr7,BSTR,bstr42,VARCMP_GT);
VARCMP(BSTR,bstr42,BSTR,bstr7,VARCMP_LT);
/* DECIMAL handling */
SETDEC(dec,0,0,0,0);
@ -5148,6 +5164,11 @@ static void test_VarCmp(void)
VARCMP(DATE,DATE_MIN,DATE,DATE_MIN-1,VARCMP_GT);
VARCMP(DATE,R8_MIN,R8,R8_MIN,VARCMP_EQ);
VARCMP(DATE,1,DATE,1+1e-15,VARCMP_LT); /* 1e-15 == 8.64e-11 seconds */
VARCMP(DATE,25570.0,DATE,25570.0,VARCMP_EQ);
VARCMP(DATE,25570.0,DATE,25571.0,VARCMP_LT);
VARCMP(DATE,25571.0,DATE,25570.0,VARCMP_GT);
VARCMP(DATE,25570.0,EMPTY,0,VARCMP_GT);
VARCMP(DATE,25570.0,NULL_,0,VARCMP_NULL);
/* R4 precission handling */
VARCMP(R4,1,R8,1+1e-8,VARCMP_EQ);

View File

@ -77,13 +77,6 @@ int val_empty, val_null;
#define VARINIT( A, type, value) V_VT(A) = VT##type; V##type(A) = value
/* Macro for VarCmp*/
#define VARCMP(left, ltype, lvalue, right, rtype, rvalue, lcid, flags) \
VARINIT(left, ltype, lvalue); \
VARINIT(right, rtype, rvalue); \
hres = pVarCmp(left, right, lcid, flags)
/* Macros for converting and testing results */
#define CONVVARS(typ) HRESULT hres; CONV_TYPE out; typ in
@ -518,8 +511,6 @@ static HRESULT (WINAPI *pVarBstrFromDate)(DATE,LCID,ULONG,BSTR*);
static HRESULT (WINAPI *pVarBstrFromDec)(DECIMAL*,LCID,ULONG,BSTR*);
static HRESULT (WINAPI *pVarBstrCmp)(BSTR,BSTR,LCID,ULONG);
static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
static INT (WINAPI *pSystemTimeToVariantTime)(LPSYSTEMTIME,double*);
static void (WINAPI *pClearCustData)(LPCUSTDATA);
@ -4717,62 +4708,6 @@ static void test_VarBoolChangeTypeEx(void)
}
}
#undef EXPECT_LT
#undef EXPECT_GT
#undef EXPECT_EQ
#undef EXPECT_NULL
#undef EXPECTRES
#define EXPECTRES(res) ok(hres == res, "expected " #res ", got hres=0x%08lx\n", hres)
#define EXPECT_LT EXPECTRES(VARCMP_LT)
#define EXPECT_GT EXPECTRES(VARCMP_GT)
#define EXPECT_EQ EXPECTRES(VARCMP_EQ)
#define EXPECT_NULL EXPECTRES(VARCMP_NULL)
static void test_VarCmp(void)
{
HRESULT hres;
VARIANTARG left, right;
LCID lcid;
WCHAR szvalNULL[] = { '0',0 };
WCHAR szval100[] = { '1','0','0',0 };
WCHAR szval101[] = { '1','0','1',0 };
BSTR bzvalNULL, bzval100, bzval101;
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
bzvalNULL=SysAllocString(szvalNULL);
bzval100=SysAllocString(szval100);
bzval101=SysAllocString(szval101);
CHECKPTR(VarCmp);
VARCMP(&left, _DATE, 25570.0, &right, _DATE, 25570.0, lcid, 0); EXPECT_EQ;
VARCMP(&left, _DATE, 25570.0, &right, _DATE, 25571.0, lcid, 0); EXPECT_LT;
VARCMP(&left, _DATE, 25571.0, &right, _DATE, 25570.0, lcid, 0); EXPECT_GT;
VARCMP(&left, _DATE, 25570.0, &right, _EMPTY, 0, lcid, 0); EXPECT_GT;
VARCMP(&left, _DATE, 25570.0, &right, _NULL, 0, lcid, 0); EXPECT_NULL;
VARCMP(&left, _I2, 2, &right, _I2, 2, lcid, 0); EXPECT_EQ;
VARCMP(&left, _I2, 1, &right, _I2, 2, lcid, 0); EXPECT_LT;
VARCMP(&left, _I2, 2, &right, _I2, 1, lcid, 0); EXPECT_GT;
VARCMP(&left, _I2, 2, &right, _EMPTY, 1, lcid, 0); EXPECT_GT;
VARCMP(&left, _I2, 2, &right, _NULL, 1, lcid, 0); EXPECT_NULL;
VARCMP(&left, _BSTR, NULL, &right, _EMPTY, 0, lcid, 0); EXPECT_EQ;
VARCMP(&left, _EMPTY, 0, &right, _BSTR, NULL, lcid, 0); EXPECT_EQ;
VARCMP(&left, _EMPTY, 0, &right, _BSTR, bzval100, lcid, 0); EXPECT_LT;
VARCMP(&left, _BSTR, bzvalNULL, &right, _EMPTY, 0, lcid, 0); EXPECT_GT;
VARCMP(&left, _BSTR, bzvalNULL, &right, _NULL, 0, lcid, 0); EXPECT_NULL;
VARCMP(&left, _BSTR, bzvalNULL, &right, _I2, 0, lcid, 0); EXPECT_GT;
VARCMP(&left, _BSTR, bzvalNULL, &right, _NULL, 0, lcid, 0); EXPECT_NULL;
VARCMP(&left, _BSTR, bzval100, &right, _BSTR, bzval100, lcid, 0); EXPECT_EQ;
VARCMP(&left, _BSTR, bzval100, &right, _BSTR, bzval101, lcid, 0); EXPECT_LT;
VARCMP(&left, _BSTR, bzval101, &right, _BSTR, bzval100, lcid, 0); EXPECT_GT;
VARCMP(&left, _BSTR, bzval100, &right, _I2, 100, lcid, 0); EXPECT_GT;
VARCMP(&left, _BSTR, bzval100, &right, _I2, 101, lcid, 0); EXPECT_GT;
VARCMP(&left, _BSTR, bzval100, &right, _I2, 101, lcid, 0); EXPECT_GT;
VARCMP(&left, _I2, 100, &right, _BSTR, bzval100, lcid, 0); EXPECT_LT;
VARCMP(&left, _BSTR, (BSTR)100, &right, _I2, 100, lcid, 0); EXPECT_GT;
SysFreeString(szval101);
SysFreeString(szval100);
SysFreeString(szvalNULL);
}
/*
* BSTR
*/
@ -5994,8 +5929,6 @@ START_TEST(vartype)
test_VarBoolCopy();
test_VarBoolChangeTypeEx();
test_VarCmp();
test_VarBstrFromR4();
test_VarBstrFromDate();
test_VarBstrFromDec();