Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
87df0745
Commit
87df0745
authored
Nov 03, 2005
by
Uwe Bonnes
Committed by
Alexandre Julliard
Nov 03, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend VarCmp() and add test cases.
parent
935dea2f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
2 deletions
+127
-2
vartype.c
dlls/oleaut32/tests/vartype.c
+76
-0
variant.c
dlls/oleaut32/variant.c
+51
-2
No files found.
dlls/oleaut32/tests/vartype.c
View file @
87df0745
...
@@ -68,6 +68,22 @@ static HMODULE hOleaut32;
...
@@ -68,6 +68,22 @@ static HMODULE hOleaut32;
#define IS_MODERN_VTYPE(vt) (vt==VT_VARIANT||vt==VT_DECIMAL|| \
#define IS_MODERN_VTYPE(vt) (vt==VT_VARIANT||vt==VT_DECIMAL|| \
vt==VT_I1||vt==VT_UI2||vt==VT_UI4||vt == VT_INT||vt == VT_UINT)
vt==VT_I1||vt==VT_UI2||vt==VT_UI4||vt == VT_INT||vt == VT_UINT)
/* Macro for setting typ and initializing */
/* First some dummy definitions*/
int
val_empty
,
val_null
;
#define V_EMPTY(x) val_empty
#define V_NULL(x) 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 */
/* Macros for converting and testing results */
#define CONVVARS(typ) HRESULT hres; CONV_TYPE out; typ in
#define CONVVARS(typ) HRESULT hres; CONV_TYPE out; typ in
...
@@ -501,6 +517,8 @@ static HRESULT (WINAPI *pVarBstrFromR4)(FLOAT,LCID,ULONG,BSTR*);
...
@@ -501,6 +517,8 @@ static HRESULT (WINAPI *pVarBstrFromR4)(FLOAT,LCID,ULONG,BSTR*);
static
HRESULT
(
WINAPI
*
pVarBstrFromDate
)(
DATE
,
LCID
,
ULONG
,
BSTR
*
);
static
HRESULT
(
WINAPI
*
pVarBstrFromDate
)(
DATE
,
LCID
,
ULONG
,
BSTR
*
);
static
HRESULT
(
WINAPI
*
pVarBstrFromDec
)(
DECIMAL
*
,
LCID
,
ULONG
,
BSTR
*
);
static
HRESULT
(
WINAPI
*
pVarBstrFromDec
)(
DECIMAL
*
,
LCID
,
ULONG
,
BSTR
*
);
static
HRESULT
(
WINAPI
*
pVarCmp
)(
LPVARIANT
,
LPVARIANT
,
LCID
,
ULONG
);
static
INT
(
WINAPI
*
pSystemTimeToVariantTime
)(
LPSYSTEMTIME
,
double
*
);
static
INT
(
WINAPI
*
pSystemTimeToVariantTime
)(
LPSYSTEMTIME
,
double
*
);
static
void
(
WINAPI
*
pClearCustData
)(
LPCUSTDATA
);
static
void
(
WINAPI
*
pClearCustData
)(
LPCUSTDATA
);
...
@@ -4698,6 +4716,62 @@ static void test_VarBoolChangeTypeEx(void)
...
@@ -4698,6 +4716,62 @@ 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
* BSTR
*/
*/
...
@@ -5889,6 +5963,8 @@ START_TEST(vartype)
...
@@ -5889,6 +5963,8 @@ START_TEST(vartype)
test_VarBoolCopy
();
test_VarBoolCopy
();
test_VarBoolChangeTypeEx
();
test_VarBoolChangeTypeEx
();
test_VarCmp
();
test_VarBstrFromR4
();
test_VarBstrFromR4
();
test_VarBstrFromDate
();
test_VarBstrFromDate
();
test_VarBstrFromDec
();
test_VarBstrFromDec
();
...
...
dlls/oleaut32/variant.c
View file @
87df0745
...
@@ -2512,11 +2512,14 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
...
@@ -2512,11 +2512,14 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
{
{
BOOL
lOk
=
TRUE
;
BOOL
lOk
=
TRUE
;
BOOL
rOk
=
TRUE
;
BOOL
rOk
=
TRUE
;
BOOL
l_isR
=
FALSE
;
BOOL
r_isR
=
FALSE
;
LONGLONG
lVal
=
-
1
;
LONGLONG
lVal
=
-
1
;
LONGLONG
rVal
=
-
1
;
LONGLONG
rVal
=
-
1
;
VARIANT
rv
,
lv
;
VARIANT
rv
,
lv
;
DWORD
xmask
;
DWORD
xmask
;
HRESULT
rc
;
HRESULT
rc
;
double
lDouble
=
0
.
0
,
rDouble
=
0
.
0
;
TRACE
(
"(%p->(%s%s),%p->(%s%s),0x%08lx,0x%08lx)
\n
"
,
left
,
debugstr_VT
(
left
),
TRACE
(
"(%p->(%s%s),%p->(%s%s),0x%08lx,0x%08lx)
\n
"
,
left
,
debugstr_VT
(
left
),
debugstr_VF
(
left
),
right
,
debugstr_VT
(
right
),
debugstr_VF
(
right
),
lcid
,
flags
);
debugstr_VF
(
left
),
right
,
debugstr_VT
(
right
),
debugstr_VF
(
right
),
lcid
,
flags
);
...
@@ -2581,6 +2584,8 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
...
@@ -2581,6 +2584,8 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
case
VT_UINT
:
lVal
=
V_UI4
(
left
);
break
;
case
VT_UINT
:
lVal
=
V_UI4
(
left
);
break
;
case
VT_BOOL
:
lVal
=
V_BOOL
(
left
);
break
;
case
VT_BOOL
:
lVal
=
V_BOOL
(
left
);
break
;
case
VT_EMPTY
:
lVal
=
0
;
break
;
case
VT_EMPTY
:
lVal
=
0
;
break
;
case
VT_R4
:
lDouble
=
V_R4
(
left
);
lOk
=
FALSE
;
l_isR
=
TRUE
;
break
;
case
VT_R8
:
lDouble
=
V_R8
(
left
);
lOk
=
FALSE
;
l_isR
=
TRUE
;
break
;
default:
lOk
=
FALSE
;
default:
lOk
=
FALSE
;
}
}
...
@@ -2596,6 +2601,8 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
...
@@ -2596,6 +2601,8 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
case
VT_UINT
:
rVal
=
V_UI4
(
right
);
break
;
case
VT_UINT
:
rVal
=
V_UI4
(
right
);
break
;
case
VT_BOOL
:
rVal
=
V_BOOL
(
right
);
break
;
case
VT_BOOL
:
rVal
=
V_BOOL
(
right
);
break
;
case
VT_EMPTY
:
rVal
=
0
;
break
;
case
VT_EMPTY
:
rVal
=
0
;
break
;
case
VT_R4
:
rDouble
=
V_R4
(
right
);
rOk
=
FALSE
;
r_isR
=
TRUE
;
break
;
case
VT_R8
:
rDouble
=
V_R8
(
right
);
rOk
=
FALSE
;
r_isR
=
TRUE
;
break
;
default:
rOk
=
FALSE
;
default:
rOk
=
FALSE
;
}
}
...
@@ -2608,7 +2615,47 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
...
@@ -2608,7 +2615,47 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
return
VARCMP_EQ
;
return
VARCMP_EQ
;
}
}
}
}
else
if
(
l_isR
&&
r_isR
)
{
if
(
lDouble
<
rDouble
)
{
return
VARCMP_LT
;
}
else
if
(
lDouble
>
rDouble
)
{
return
VARCMP_GT
;
}
else
{
return
VARCMP_EQ
;
}
}
else
if
(
lOk
&&
r_isR
)
{
if
(
lVal
<
rDouble
)
{
return
VARCMP_LT
;
}
else
if
(
lVal
>
rDouble
)
{
return
VARCMP_GT
;
}
else
{
return
VARCMP_EQ
;
}
}
else
if
(
l_isR
&&
rOk
)
{
if
(
lDouble
<
rVal
)
{
return
VARCMP_LT
;
}
else
if
(
lDouble
>
rVal
)
{
return
VARCMP_GT
;
}
else
{
return
VARCMP_EQ
;
}
}
if
((
V_VT
(
left
)
&
VT_TYPEMASK
)
==
VT_BSTR
)
{
if
(((
V_VT
(
right
)
&
VT_TYPEMASK
)
==
VT_EMPTY
)
&&
!
(
V_BSTR
(
left
)))
{
return
VARCMP_EQ
;
}
else
{
return
VARCMP_GT
;
}
}
if
((
V_VT
(
right
)
&
VT_TYPEMASK
)
==
VT_BSTR
)
{
if
(((
V_VT
(
left
)
&
VT_TYPEMASK
)
==
VT_EMPTY
)
&&
!
(
V_BSTR
(
right
)))
{
return
VARCMP_EQ
;
}
else
{
return
VARCMP_LT
;
}
}
/* Dates */
/* Dates */
if
((
V_VT
(
left
)
&
VT_TYPEMASK
)
==
VT_DATE
&&
if
((
V_VT
(
left
)
&
VT_TYPEMASK
)
==
VT_DATE
&&
(
V_VT
(
right
)
&
VT_TYPEMASK
)
==
VT_DATE
)
{
(
V_VT
(
right
)
&
VT_TYPEMASK
)
==
VT_DATE
)
{
...
@@ -2642,7 +2689,9 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
...
@@ -2642,7 +2689,9 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
return
VARCMP_GT
;
return
VARCMP_GT
;
}
}
}
}
FIXME
(
"VarCmp partial implementation, doesn't support vt 0x%x / 0x%x
\n
"
,
V_VT
(
left
),
V_VT
(
right
));
else
if
((
V_VT
(
right
)
&
VT_TYPEMASK
)
==
VT_EMPTY
)
return
VARCMP_GT
;
FIXME
(
"VarCmp partial implementation, doesn't support %s / %s
\n
"
,
wine_vtypes
[
V_VT
(
left
)],
wine_vtypes
[
V_VT
(
right
)]);
return
E_FAIL
;
return
E_FAIL
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment