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
58ea6bdd
Commit
58ea6bdd
authored
Sep 22, 2017
by
Fabian Maurer
Committed by
Alexandre Julliard
Sep 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
propsys: Added PropVariantToBoolean with some tests.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
02641e33
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
277 additions
and
1 deletion
+277
-1
propsys.spec
dlls/propsys/propsys.spec
+1
-1
propvar.c
dlls/propsys/propvar.c
+60
-0
propsys.c
dlls/propsys/tests/propsys.c
+215
-0
propvarutil.h
include/propvarutil.h
+1
-0
No files found.
dlls/propsys/propsys.spec
View file @
58ea6bdd
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
@ stub PropVariantGetUInt32Elem
@ stub PropVariantGetUInt32Elem
@ stub PropVariantGetUInt64Elem
@ stub PropVariantGetUInt64Elem
@ stub PropVariantToBSTR
@ stub PropVariantToBSTR
@ st
ub PropVariantToBoolean
@ st
dcall PropVariantToBoolean(ptr ptr)
@ stub PropVariantToBooleanVector
@ stub PropVariantToBooleanVector
@ stub PropVariantToBooleanVectorAlloc
@ stub PropVariantToBooleanVectorAlloc
@ stub PropVariantToBooleanWithDefault
@ stub PropVariantToBooleanWithDefault
...
...
dlls/propsys/propvar.c
View file @
58ea6bdd
...
@@ -227,6 +227,66 @@ HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
...
@@ -227,6 +227,66 @@ HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
return
hr
;
return
hr
;
}
}
HRESULT
WINAPI
PropVariantToBoolean
(
REFPROPVARIANT
propvarIn
,
BOOL
*
ret
)
{
static
const
WCHAR
trueW
[]
=
{
't'
,
'r'
,
'u'
,
'e'
,
0
};
static
const
WCHAR
falseW
[]
=
{
'f'
,
'a'
,
'l'
,
's'
,
'e'
,
0
};
static
const
WCHAR
true2W
[]
=
{
'#'
,
'T'
,
'R'
,
'U'
,
'E'
,
'#'
,
0
};
static
const
WCHAR
false2W
[]
=
{
'#'
,
'F'
,
'A'
,
'L'
,
'S'
,
'E'
,
'#'
,
0
};
LONGLONG
res
;
HRESULT
hr
;
TRACE
(
"%p,%p
\n
"
,
propvarIn
,
ret
);
*
ret
=
FALSE
;
switch
(
propvarIn
->
vt
)
{
case
VT_BOOL
:
*
ret
=
propvarIn
->
u
.
boolVal
==
VARIANT_TRUE
;
return
S_OK
;
case
VT_LPWSTR
:
case
VT_BSTR
:
if
(
!
propvarIn
->
u
.
pwszVal
)
return
DISP_E_TYPEMISMATCH
;
if
(
!
lstrcmpiW
(
propvarIn
->
u
.
pwszVal
,
trueW
)
||
!
lstrcmpW
(
propvarIn
->
u
.
pwszVal
,
true2W
))
{
*
ret
=
TRUE
;
return
S_OK
;
}
if
(
!
lstrcmpiW
(
propvarIn
->
u
.
pwszVal
,
falseW
)
||
!
lstrcmpW
(
propvarIn
->
u
.
pwszVal
,
false2W
))
{
*
ret
=
FALSE
;
return
S_OK
;
}
break
;
case
VT_LPSTR
:
if
(
!
propvarIn
->
u
.
pszVal
)
return
DISP_E_TYPEMISMATCH
;
if
(
!
lstrcmpiA
(
propvarIn
->
u
.
pszVal
,
"true"
)
||
!
lstrcmpA
(
propvarIn
->
u
.
pszVal
,
"#TRUE#"
))
{
*
ret
=
TRUE
;
return
S_OK
;
}
if
(
!
lstrcmpiA
(
propvarIn
->
u
.
pszVal
,
"false"
)
||
!
lstrcmpA
(
propvarIn
->
u
.
pszVal
,
"#FALSE#"
))
{
*
ret
=
FALSE
;
return
S_OK
;
}
break
;
}
hr
=
PROPVAR_ConvertNumber
(
propvarIn
,
64
,
FALSE
,
&
res
);
*
ret
=
!!
res
;
return
hr
;
}
HRESULT
WINAPI
PropVariantToStringAlloc
(
REFPROPVARIANT
propvarIn
,
WCHAR
**
ret
)
HRESULT
WINAPI
PropVariantToStringAlloc
(
REFPROPVARIANT
propvarIn
,
WCHAR
**
ret
)
{
{
WCHAR
*
res
=
NULL
;
WCHAR
*
res
=
NULL
;
...
...
dlls/propsys/tests/propsys.c
View file @
58ea6bdd
...
@@ -883,6 +883,220 @@ static void test_intconversions(void)
...
@@ -883,6 +883,220 @@ static void test_intconversions(void)
ok
(
llval
==
-
7
,
"got wrong value %s
\n
"
,
wine_dbgstr_longlong
(
llval
));
ok
(
llval
==
-
7
,
"got wrong value %s
\n
"
,
wine_dbgstr_longlong
(
llval
));
}
}
static
void
test_PropVariantToBoolean
(
void
)
{
static
WCHAR
str_0
[]
=
{
'0'
,
0
};
static
WCHAR
str_1
[]
=
{
'1'
,
0
};
static
WCHAR
str_7
[]
=
{
'7'
,
0
};
static
WCHAR
str_n7
[]
=
{
'-'
,
'7'
,
0
};
static
WCHAR
str_true
[]
=
{
't'
,
'r'
,
'u'
,
'e'
,
0
};
static
WCHAR
str_true2
[]
=
{
'#'
,
'T'
,
'R'
,
'U'
,
'E'
,
'#'
,
0
};
static
WCHAR
str_true_case
[]
=
{
't'
,
'R'
,
'U'
,
'e'
,
0
};
static
WCHAR
str_false
[]
=
{
'f'
,
'a'
,
'l'
,
's'
,
'e'
,
0
};
static
WCHAR
str_false2
[]
=
{
'#'
,
'F'
,
'A'
,
'L'
,
'S'
,
'E'
,
'#'
,
0
};
static
WCHAR
str_true_space
[]
=
{
't'
,
'r'
,
'u'
,
'e'
,
' '
,
0
};
static
WCHAR
str_yes
[]
=
{
'y'
,
'e'
,
's'
,
0
};
PROPVARIANT
propvar
;
HRESULT
hr
;
BOOL
val
;
/* VT_BOOL */
propvar
.
vt
=
VT_BOOL
;
propvar
.
u
.
boolVal
=
VARIANT_FALSE
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_BOOL
;
propvar
.
u
.
boolVal
=
1
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_BOOL
;
propvar
.
u
.
boolVal
=
VARIANT_TRUE
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
/* VT_EMPTY */
propvar
.
vt
=
VT_EMPTY
;
propvar
.
u
.
boolVal
=
VARIANT_TRUE
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
/* test integer conversion */
propvar
.
vt
=
VT_I4
;
propvar
.
u
.
lVal
=
0
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_I4
;
propvar
.
u
.
lVal
=
1
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_I4
;
propvar
.
u
.
lVal
=
67
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_I4
;
propvar
.
u
.
lVal
=
-
67
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
/* test string conversion */
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_0
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_1
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_7
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_n7
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_true
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_true_case
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_true2
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_false
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_false2
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_true_space
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
DISP_E_TYPEMISMATCH
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
str_yes
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
DISP_E_TYPEMISMATCH
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPWSTR
;
propvar
.
u
.
pwszVal
=
NULL
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
DISP_E_TYPEMISMATCH
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
/* VT_LPSTR */
propvar
.
vt
=
VT_LPSTR
;
propvar
.
u
.
pszVal
=
(
char
*
)
"#TruE#"
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
DISP_E_TYPEMISMATCH
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPSTR
;
propvar
.
u
.
pszVal
=
(
char
*
)
"#TRUE#"
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPSTR
;
propvar
.
u
.
pszVal
=
(
char
*
)
"tRUe"
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPSTR
;
propvar
.
u
.
pszVal
=
(
char
*
)
"#FALSE#"
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPSTR
;
propvar
.
u
.
pszVal
=
(
char
*
)
"fALSe"
;
val
=
TRUE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
FALSE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPSTR
;
propvar
.
u
.
pszVal
=
(
char
*
)
"1"
;
val
=
FALSE
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
propvar
.
vt
=
VT_LPSTR
;
propvar
.
u
.
pszVal
=
(
char
*
)
"-1"
;
hr
=
PropVariantToBoolean
(
&
propvar
,
&
val
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
val
==
TRUE
,
"Unexpected value %d
\n
"
,
val
);
}
static
void
test_PropVariantChangeType_LPWSTR
(
void
)
static
void
test_PropVariantChangeType_LPWSTR
(
void
)
{
{
PROPVARIANT
dest
,
src
;
PROPVARIANT
dest
,
src
;
...
@@ -931,4 +1145,5 @@ START_TEST(propsys)
...
@@ -931,4 +1145,5 @@ START_TEST(propsys)
test_PropVariantCompare
();
test_PropVariantCompare
();
test_intconversions
();
test_intconversions
();
test_PropVariantChangeType_LPWSTR
();
test_PropVariantChangeType_LPWSTR
();
test_PropVariantToBoolean
();
}
}
include/propvarutil.h
View file @
58ea6bdd
...
@@ -76,6 +76,7 @@ HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret);
...
@@ -76,6 +76,7 @@ HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret);
HRESULT
WINAPI
PropVariantToUInt16
(
REFPROPVARIANT
propvarIn
,
USHORT
*
ret
);
HRESULT
WINAPI
PropVariantToUInt16
(
REFPROPVARIANT
propvarIn
,
USHORT
*
ret
);
HRESULT
WINAPI
PropVariantToUInt32
(
REFPROPVARIANT
propvarIn
,
ULONG
*
ret
);
HRESULT
WINAPI
PropVariantToUInt32
(
REFPROPVARIANT
propvarIn
,
ULONG
*
ret
);
HRESULT
WINAPI
PropVariantToUInt64
(
REFPROPVARIANT
propvarIn
,
ULONGLONG
*
ret
);
HRESULT
WINAPI
PropVariantToUInt64
(
REFPROPVARIANT
propvarIn
,
ULONGLONG
*
ret
);
HRESULT
WINAPI
PropVariantToBoolean
(
REFPROPVARIANT
propvarIn
,
BOOL
*
ret
);
HRESULT
WINAPI
PropVariantToStringAlloc
(
REFPROPVARIANT
propvarIn
,
WCHAR
**
ret
);
HRESULT
WINAPI
PropVariantToStringAlloc
(
REFPROPVARIANT
propvarIn
,
WCHAR
**
ret
);
...
...
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