4 * Copyright 2004 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 /* not present in Wine yet */
23 /*#include "propidl.h"*/
24 WINOLEAPI
PropVariantClear(PROPVARIANT
*);
25 WINOLEAPI
PropVariantCopy(PROPVARIANT
*, const PROPVARIANT
*);
27 #include "wine/test.h"
29 #ifdef NONAMELESSUNION
43 { TRUE
, FALSE
, FALSE
, FALSE
}, /* VT_EMPTY */
44 { TRUE
, FALSE
, FALSE
, FALSE
}, /* VT_NULL */
45 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_I2 */
46 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_I4 */
47 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_R4 */
48 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_R8 */
49 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_CY */
50 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_DATE */
51 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_BSTR */
52 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_DISPATCH */
53 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_ERROR */
54 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_BOOL */
55 { FALSE
, FALSE
, TRUE
, FALSE
}, /* VT_VARIANT */
56 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_UNKNOWN */
57 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_DECIMAL */
58 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 15 */
59 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_I1 */
60 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_UI1 */
61 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_UI2 */
62 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_UI4 */
63 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_I8 */
64 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_UI8 */
65 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_INT */
66 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_UINT */
67 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_VOID */
68 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_HRESULT */
69 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_PTR */
70 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_SAFEARRAY */
71 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_CARRAY */
72 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_USERDEFINED */
73 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_LPSTR */
74 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_LPWSTR */
75 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 32 */
76 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 33 */
77 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 34 */
78 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 35 */
79 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_RECORD */
80 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_INT_PTR */
81 { FALSE
, FALSE
, FALSE
, FALSE
}, /* VT_UINT_PTR */
82 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 39 */
83 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 40 */
84 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 41 */
85 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 42 */
86 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 43 */
87 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 44 */
88 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 45 */
89 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 46 */
90 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 47 */
91 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 48 */
92 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 49 */
93 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 50 */
94 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 51 */
95 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 52 */
96 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 53 */
97 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 54 */
98 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 55 */
99 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 56 */
100 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 57 */
101 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 58 */
102 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 59 */
103 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 60 */
104 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 61 */
105 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 62 */
106 { FALSE
, FALSE
, FALSE
, FALSE
}, /* 63 */
107 { TRUE
, FALSE
, TRUE
, FALSE
}, /* VT_FILETIME */
108 { TRUE
, FALSE
, FALSE
, FALSE
}, /* VT_BLOB */
109 { TRUE
, FALSE
, FALSE
, FALSE
}, /* VT_STREAM */
110 { TRUE
, FALSE
, FALSE
, FALSE
}, /* VT_STORAGE */
111 { TRUE
, FALSE
, FALSE
, FALSE
}, /* VT_STREAMED_OBJECT */
112 { TRUE
, FALSE
, FALSE
, FALSE
}, /* VT_STORED_OBJECT */
113 { TRUE
, FALSE
, FALSE
, FALSE
}, /* VT_BLOB_OBJECT */
114 { TRUE
, FALSE
, TRUE
, FALSE
} /* VT_CF */
117 static const char* wine_vtypes
[VT_CLSID
+1] =
119 "VT_EMPTY","VT_NULL","VT_I2","VT_I4","VT_R4","VT_R8","VT_CY","VT_DATE",
120 "VT_BSTR","VT_DISPATCH","VT_ERROR","VT_BOOL","VT_VARIANT","VT_UNKNOWN",
121 "VT_DECIMAL","15","VT_I1","VT_UI1","VT_UI2","VT_UI4","VT_I8","VT_UI8",
122 "VT_INT","VT_UINT","VT_VOID","VT_HRESULT","VT_PTR","VT_SAFEARRAY",
123 "VT_CARRAY","VT_USERDEFINED","VT_LPSTR","VT_LPWSTR","32","33","34","35",
124 "VT_RECORD","VT_INT_PTR","VT_UINT_PTR","39","40","41","42","43","44","45",
125 "46","47","48","49","50","51","52","53","54","55","56","57","58","59","60",
126 "61","62","63","VT_FILETIME","VT_BLOB","VT_STREAM","VT_STORAGE",
127 "VT_STREAMED_OBJECT","VT_STORED_OBJECT","VT_BLOB_OBJECT","VT_CF","VT_CLSID"
130 static void test_validtypes()
136 memset(&propvar
, 0, sizeof(propvar
));
138 for (i
= 0; i
< sizeof(valid_types
)/sizeof(valid_types
[0]); i
++)
141 hr
= PropVariantClear(&propvar
);
142 ok(valid_types
[i
].simple
== !(hr
== STG_E_INVALIDPARAMETER
),
143 "PropVariantClear(%s) should have returned 0x%08lx, but returned 0x%08lx\n",
145 valid_types
[i
].simple
? S_OK
: STG_E_INVALIDPARAMETER
, hr
);
147 propvar
.vt
= i
| VT_ARRAY
;
148 hr
= PropVariantClear(&propvar
);
149 ok(valid_types
[i
].with_array
== !(hr
== STG_E_INVALIDPARAMETER
),
150 "PropVariantClear(%s|VT_ARRAY) should have returned 0x%08lx, but returned 0x%08lx\n",
152 valid_types
[i
].with_array
? S_OK
: STG_E_INVALIDPARAMETER
, hr
);
154 propvar
.vt
= i
| VT_VECTOR
;
155 hr
= PropVariantClear(&propvar
);
156 ok(valid_types
[i
].with_vector
== !(hr
== STG_E_INVALIDPARAMETER
),
157 "PropVariantClear(%s|VT_VECTOR) should have returned 0x%08lx, but returned 0x%08lx\n",
159 valid_types
[i
].with_vector
? S_OK
: STG_E_INVALIDPARAMETER
, hr
);
161 propvar
.vt
= i
| VT_BYREF
;
162 hr
= PropVariantClear(&propvar
);
163 ok(valid_types
[i
].byref
== !(hr
== STG_E_INVALIDPARAMETER
),
164 "PropVariantClear(%s|VT_BYREF) should have returned 0x%08lx, but returned 0x%08lx\n",
166 valid_types
[i
].byref
? S_OK
: STG_E_INVALIDPARAMETER
, hr
);
170 static void test_copy()
172 static const char szTestString
[] = "Test String";
173 static const WCHAR wszTestString
[] = {'T','e','s','t',' ','S','t','r','i','n','g',0};
174 PROPVARIANT propvarSrc
;
175 PROPVARIANT propvarDst
;
178 propvarSrc
.vt
= VT_BSTR
;
179 U(propvarSrc
).bstrVal
= SysAllocString(wszTestString
);
181 hr
= PropVariantCopy(&propvarDst
, &propvarSrc
);
182 ok(hr
== S_OK
, "PropVariantCopy(...VT_BSTR...) failed\n");
183 ok(!lstrcmpW(U(propvarSrc
).bstrVal
, U(propvarDst
).bstrVal
), "BSTR not copied properly\n");
184 hr
= PropVariantClear(&propvarSrc
);
185 ok(hr
== S_OK
, "PropVariantClear(...VT_BSTR...) failed\n");
186 hr
= PropVariantClear(&propvarDst
);
187 ok(hr
== S_OK
, "PropVariantClear(...VT_BSTR...) failed\n");
189 propvarSrc
.vt
= VT_LPWSTR
;
190 U(propvarSrc
).pwszVal
= (LPWSTR
)wszTestString
;
191 hr
= PropVariantCopy(&propvarDst
, &propvarSrc
);
192 ok(hr
== S_OK
, "PropVariantCopy(...VT_LPWSTR...) failed\n");
193 ok(!lstrcmpW(U(propvarSrc
).pwszVal
, U(propvarDst
).pwszVal
), "Wide string not copied properly\n");
194 hr
= PropVariantClear(&propvarDst
);
195 ok(hr
== S_OK
, "PropVariantClear(...VT_LPWSTR...) failed\n");
196 memset(&propvarSrc
, 0, sizeof(propvarSrc
));
198 propvarSrc
.vt
= VT_LPSTR
;
199 U(propvarSrc
).pszVal
= (LPSTR
)szTestString
;
200 hr
= PropVariantCopy(&propvarDst
, &propvarSrc
);
201 ok(hr
== S_OK
, "PropVariantCopy(...VT_LPSTR...) failed\n");
202 ok(!strcmp(U(propvarSrc
).pszVal
, U(propvarDst
).pszVal
), "String not copied properly\n");
203 hr
= PropVariantClear(&propvarDst
);
204 ok(hr
== S_OK
, "PropVariantClear(...VT_LPSTR...) failed\n");
205 memset(&propvarSrc
, 0, sizeof(propvarSrc
));
208 START_TEST(propvariant
)