2 * Unit tests for Windows property system
4 * Copyright 2006 Paul Vriens
5 * Copyright 2010 Andrew Nguyen
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_NO_STATUS
24 #define COM_NO_WINDOWS_H
31 #define NONAMELESSUNION
37 //#include "objbase.h"
41 #include <propvarutil.h>
42 #include <wine/test.h>
44 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
45 DEFINE_GUID(dummy_guid
, 0xdeadbeef, 0xdead, 0xbeef, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe);
46 DEFINE_GUID(expect_guid
, 0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12);
48 #define GUID_MEMBERS(g) {(g).Data1, (g).Data2, (g).Data3, {(g).Data4[0], (g).Data4[1], (g).Data4[2], (g).Data4[3], (g).Data4[4], (g).Data4[5], (g).Data4[6], (g).Data4[7]}}
50 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
53 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
54 return lstrcmpA(stra
, buf
);
57 static void test_PSStringFromPropertyKey(void)
59 static const WCHAR fillerW
[] = {'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
60 'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
61 'X','X','X','X','X','X','X','X','X','X'};
62 static const WCHAR zero_fillerW
[] = {'\0','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
63 'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
64 'X','X','X','X','X','X','X','X','X','X','X','X','X','X'};
65 static const WCHAR zero_truncatedW
[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
66 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
67 '0','0','0','}',' ','\0','9','X','X','X','X','X','X','X','X','X'};
68 static const WCHAR zero_truncated2W
[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
69 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
70 '0','0','0','}',' ','\0','9','2','7','6','9','4','9','2','X','X'};
71 static const WCHAR zero_truncated3W
[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
72 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
73 '0','0','0','}',' ','\0','9','2','7','6','9','4','9','2','4','X'};
74 static const WCHAR zero_truncated4W
[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
75 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
76 '0','0','0','}',' ','\0','7','X','X','X','X','X','X','X','X','X'};
77 static const WCHAR truncatedW
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
78 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
79 '0','}',' ','\0','9','X','X','X','X','X','X','X','X','X'};
80 static const WCHAR truncated2W
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
81 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
82 '0','}',' ','\0','9','2','7','6','9','4','9','2','X','X'};
83 static const WCHAR truncated3W
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
84 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
85 '0','}',' ','\0','9','2','7','6','9','4','9','2','4','X'};
86 static const WCHAR truncated4W
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
87 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
88 '0','}',' ','\0','7','X','X','X','X','X','X','X','X','X'};
89 static const WCHAR expectedW
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
90 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
91 '0','}',' ','4','2','9','4','9','6','7','2','9','5',0};
92 static const WCHAR expected2W
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
93 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
94 '0','}',' ','1','3','5','7','9','\0','X','X','X','X','X'};
95 static const WCHAR expected3W
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
96 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
97 '0','}',' ','0','\0','X','X','X','X','X','X','X','X','X'};
98 PROPERTYKEY prop
= {GUID_MEMBERS(GUID_NULL
), ~0U};
99 PROPERTYKEY prop2
= {GUID_MEMBERS(GUID_NULL
), 13579};
100 PROPERTYKEY prop3
= {GUID_MEMBERS(GUID_NULL
), 0};
101 WCHAR out
[PKEYSTR_MAX
];
110 const WCHAR
*buf_expect
;
117 {NULL
, NULL
, 0, E_POINTER
},
118 {&prop
, NULL
, 0, E_POINTER
},
119 {&prop
, NULL
, PKEYSTR_MAX
, E_POINTER
},
120 {NULL
, out
, 0, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), fillerW
},
121 {NULL
, out
, PKEYSTR_MAX
, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), zero_fillerW
, FALSE
, 0, TRUE
, fillerW
},
122 {&prop
, out
, 0, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), fillerW
},
123 {&prop
, out
, GUIDSTRING_MAX
, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), fillerW
},
124 {&prop
, out
, GUIDSTRING_MAX
+ 1, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), fillerW
},
125 {&prop
, out
, GUIDSTRING_MAX
+ 2, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), zero_truncatedW
, TRUE
, S_OK
, TRUE
, truncatedW
},
126 {&prop
, out
, PKEYSTR_MAX
- 2, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), zero_truncated2W
, TRUE
, S_OK
, TRUE
, truncated2W
},
127 {&prop
, out
, PKEYSTR_MAX
- 1, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), zero_truncated3W
, TRUE
, S_OK
, TRUE
, truncated3W
},
128 {&prop
, out
, PKEYSTR_MAX
, S_OK
, expectedW
},
129 {&prop2
, out
, GUIDSTRING_MAX
+ 2, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), zero_truncated4W
, TRUE
, S_OK
, TRUE
, truncated4W
},
130 {&prop2
, out
, GUIDSTRING_MAX
+ 6, S_OK
, expected2W
},
131 {&prop2
, out
, PKEYSTR_MAX
, S_OK
, expected2W
},
132 {&prop3
, out
, GUIDSTRING_MAX
+ 1, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
), fillerW
},
133 {&prop3
, out
, GUIDSTRING_MAX
+ 2, S_OK
, expected3W
},
134 {&prop3
, out
, PKEYSTR_MAX
, S_OK
, expected3W
},
139 for (i
= 0; i
< sizeof(testcases
)/sizeof(testcases
[0]); i
++)
141 if (testcases
[i
].psz
)
142 memcpy(testcases
[i
].psz
, fillerW
, PKEYSTR_MAX
* sizeof(WCHAR
));
144 ret
= PSStringFromPropertyKey(testcases
[i
].pkey
,
147 ok(ret
== testcases
[i
].hr_expect
||
148 broken(testcases
[i
].hr_broken
&& ret
== testcases
[i
].hr2
), /* Vista/Win2k8 */
149 "[%d] Expected PSStringFromPropertyKey to return 0x%08x, got 0x%08x\n",
150 i
, testcases
[i
].hr_expect
, ret
);
152 if (testcases
[i
].psz
)
153 ok(!memcmp(testcases
[i
].psz
, testcases
[i
].buf_expect
, PKEYSTR_MAX
* sizeof(WCHAR
)) ||
154 broken(testcases
[i
].buf_broken
&&
155 !memcmp(testcases
[i
].psz
, testcases
[i
].buf2
, PKEYSTR_MAX
* sizeof(WCHAR
))), /* Vista/Win2k8 */
156 "[%d] Unexpected output contents\n", i
);
160 static void test_PSPropertyKeyFromString(void)
162 static const WCHAR emptyW
[] = {0};
163 static const WCHAR fmtid_clsidW
[] = {'S','t','d','F','o','n','t',' ','1',0};
164 static const WCHAR fmtid_truncatedW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
165 '1','2','3','4','-',0};
166 static const WCHAR fmtid_nobracketsW
[] = {'1','2','3','4','5','6','7','8','-','1','2','3','4','-',
167 '1','2','3','4','-','1','2','3','4','-',
168 '1','2','3','4','5','6','7','8','9','0','1','2',0};
169 static const WCHAR fmtid_badbracketW
[] = {'X','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
170 '1','2','3','4','-','1','2','3','4','-',
171 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
172 static const WCHAR fmtid_badcharW
[] = {'{','X','2','3','4','5','6','7','8','-','1','2','3','4','-',
173 '1','2','3','4','-','1','2','3','4','-',
174 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
175 static const WCHAR fmtid_badchar2W
[] = {'{','1','2','3','4','5','6','7','X','-','1','2','3','4','-',
176 '1','2','3','4','-','1','2','3','4','-',
177 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
178 static const WCHAR fmtid_baddashW
[] = {'{','1','2','3','4','5','6','7','8','X','1','2','3','4','-',
179 '1','2','3','4','-','1','2','3','4','-',
180 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
181 static const WCHAR fmtid_badchar3W
[] = {'{','1','2','3','4','5','6','7','8','-','X','2','3','4','-',
182 '1','2','3','4','-','1','2','3','4','-',
183 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
184 static const WCHAR fmtid_badchar4W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','X','-',
185 '1','2','3','4','-','1','2','3','4','-',
186 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
187 static const WCHAR fmtid_baddash2W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','X',
188 '1','2','3','4','-','1','2','3','4','-',
189 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
190 static const WCHAR fmtid_badchar5W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
191 'X','2','3','4','-','1','2','3','4','-',
192 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
193 static const WCHAR fmtid_badchar6W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
194 '1','2','3','X','-','1','2','3','4','-',
195 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
196 static const WCHAR fmtid_baddash3W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
197 '1','2','3','4','X','1','2','3','4','-',
198 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
199 static const WCHAR fmtid_badchar7W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
200 '1','2','3','4','-','X','2','3','4','-',
201 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
202 static const WCHAR fmtid_badchar8W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
203 '1','2','3','4','-','1','2','3','X','-',
204 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
205 static const WCHAR fmtid_baddash4W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
206 '1','2','3','4','-','1','2','3','4','X',
207 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
208 static const WCHAR fmtid_badchar9W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
209 '1','2','3','4','-','1','2','3','4','-',
210 'X','2','3','4','5','6','7','8','9','0','1','2','}',0};
211 static const WCHAR fmtid_badchar9_adjW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
212 '1','2','3','4','-','1','2','3','4','-',
213 '1','X','3','4','5','6','7','8','9','0','1','2','}',0};
214 static const WCHAR fmtid_badchar10W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
215 '1','2','3','4','-','1','2','3','4','-',
216 '1','2','X','4','5','6','7','8','9','0','1','2','}',0};
217 static const WCHAR fmtid_badchar11W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
218 '1','2','3','4','-','1','2','3','4','-',
219 '1','2','3','4','X','6','7','8','9','0','1','2','}',0};
220 static const WCHAR fmtid_badchar12W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
221 '1','2','3','4','-','1','2','3','4','-',
222 '1','2','3','4','5','6','X','8','9','0','1','2','}',0};
223 static const WCHAR fmtid_badchar13W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
224 '1','2','3','4','-','1','2','3','4','-',
225 '1','2','3','4','5','6','7','8','X','0','1','2','}',0};
226 static const WCHAR fmtid_badchar14W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
227 '1','2','3','4','-','1','2','3','4','-',
228 '1','2','3','4','5','6','7','8','9','0','X','2','}',0};
229 static const WCHAR fmtid_badbracket2W
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
230 '1','2','3','4','-','1','2','3','4','-',
231 '1','2','3','4','5','6','7','8','9','0','1','2','X',0};
232 static const WCHAR fmtid_spaceW
[] = {' ','{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
233 '1','2','3','4','-','1','2','3','4','-',
234 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
235 static const WCHAR fmtid_spaceendW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
236 '1','2','3','4','-','1','2','3','4','-',
237 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',0};
238 static const WCHAR fmtid_spacesendW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
239 '1','2','3','4','-','1','2','3','4','-',
240 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',' ',' ',0};
241 static const WCHAR fmtid_nopidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
242 '1','2','3','4','-','1','2','3','4','-',
243 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
244 static const WCHAR fmtid_badpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
245 '1','2','3','4','-','1','2','3','4','-',
246 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','D','E','A','D',0};
247 static const WCHAR fmtid_adjpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
248 '1','2','3','4','-','1','2','3','4','-',
249 '1','2','3','4','5','6','7','8','9','0','1','2','}','1','3','5','7','9',0};
250 static const WCHAR fmtid_spacespidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
251 '1','2','3','4','-','1','2','3','4','-',
252 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',' ',' ','1','3','5','7','9',0};
253 static const WCHAR fmtid_negpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
254 '1','2','3','4','-','1','2','3','4','-',
255 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-','1','3','5','7','9',0};
256 static const WCHAR fmtid_negnegpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
257 '1','2','3','4','-','1','2','3','4','-',
258 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-','-','1','3','5','7','9',0};
259 static const WCHAR fmtid_negnegnegpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
260 '1','2','3','4','-','1','2','3','4','-',
261 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-','-','-','1','3','5','7','9',0};
262 static const WCHAR fmtid_negspacepidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
263 '1','2','3','4','-','1','2','3','4','-',
264 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-',' ','1','3','5','7','9',0};
265 static const WCHAR fmtid_negspacenegpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
266 '1','2','3','4','-','1','2','3','4','-',
267 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-',' ','-','1','3','5','7','9',0};
268 static const WCHAR fmtid_negspacespidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
269 '1','2','3','4','-','1','2','3','4','-',
270 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-',' ','-',' ','-','1','3','5','7','9',0};
271 static const WCHAR fmtid_pospidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
272 '1','2','3','4','-','1','2','3','4','-',
273 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','+','1','3','5','7','9',0};
274 static const WCHAR fmtid_posnegpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
275 '1','2','3','4','-','1','2','3','4','-',
276 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','+','-','+','-','1','3','5','7','9',0};
277 static const WCHAR fmtid_symbolpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
278 '1','2','3','4','-','1','2','3','4','-',
279 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','+','/','$','-','1','3','5','7','9',0};
280 static const WCHAR fmtid_letterpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
281 '1','2','3','4','-','1','2','3','4','-',
282 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','A','B','C','D','1','3','5','7','9',0};
283 static const WCHAR fmtid_spacepadpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
284 '1','2','3','4','-','1','2','3','4','-',
285 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',' ',' ',' ',0};
286 static const WCHAR fmtid_spacemixpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
287 '1','2','3','4','-','1','2','3','4','-',
288 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1',' ','3',' ','5','7','9',' ',' ',' ',0};
289 static const WCHAR fmtid_tabpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
290 '1','2','3','4','-','1','2','3','4','-',
291 '1','2','3','4','5','6','7','8','9','0','1','2','}','\t','1','3','5','7','9',0};
292 static const WCHAR fmtid_hexpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
293 '1','2','3','4','-','1','2','3','4','-',
294 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','0','x','D','E','A','D',0};
295 static const WCHAR fmtid_mixedpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
296 '1','2','3','4','-','1','2','3','4','-',
297 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','A','9','B','5','C','3','D','1',0};
298 static const WCHAR fmtid_overflowpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
299 '1','2','3','4','-','1','2','3','4','-',
300 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','2','3','4','5','6','7','8','9','0','1',0};
301 static const WCHAR fmtid_commapidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
302 '1','2','3','4','-','1','2','3','4','-',
303 '1','2','3','4','5','6','7','8','9','0','1','2','}',',','1','3','5','7','9',0};
304 static const WCHAR fmtid_commaspidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
305 '1','2','3','4','-','1','2','3','4','-',
306 '1','2','3','4','5','6','7','8','9','0','1','2','}',',',',',',','1','3','5','7','9',0};
307 static const WCHAR fmtid_commaspacepidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
308 '1','2','3','4','-','1','2','3','4','-',
309 '1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','1','3','5','7','9',0};
310 static const WCHAR fmtid_spacecommapidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
311 '1','2','3','4','-','1','2','3','4','-',
312 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','1','3','5','7','9',0};
313 static const WCHAR fmtid_spccommaspcpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
314 '1','2','3','4','-','1','2','3','4','-',
315 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','1','3','5','7','9',0};
316 static const WCHAR fmtid_spacescommaspidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
317 '1','2','3','4','-','1','2','3','4','-',
318 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ',',','1','3','5','7','9',0};
319 static const WCHAR fmtid_commanegpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
320 '1','2','3','4','-','1','2','3','4','-',
321 '1','2','3','4','5','6','7','8','9','0','1','2','}',',','-','1','3','5','7','9',0};
322 static const WCHAR fmtid_spccommanegpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
323 '1','2','3','4','-','1','2','3','4','-',
324 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','-','1','3','5','7','9',0};
325 static const WCHAR fmtid_commaspcnegpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
326 '1','2','3','4','-','1','2','3','4','-',
327 '1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','-','1','3','5','7','9',0};
328 static const WCHAR fmtid_spccommaspcnegpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
329 '1','2','3','4','-','1','2','3','4','-',
330 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','-','1','3','5','7','9',0};
331 static const WCHAR fmtid_commanegspcpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
332 '1','2','3','4','-','1','2','3','4','-',
333 '1','2','3','4','5','6','7','8','9','0','1','2','}',',','-',' ','1','3','5','7','9',0};
334 static const WCHAR fmtid_negcommapidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
335 '1','2','3','4','-','1','2','3','4','-',
336 '1','2','3','4','5','6','7','8','9','0','1','2','}','-',',','1','3','5','7','9',0};
337 static const WCHAR fmtid_normalpidW
[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
338 '1','2','3','4','-','1','2','3','4','-',
339 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',0};
340 PROPERTYKEY out_init
= {GUID_MEMBERS(dummy_guid
), 0xdeadbeef};
349 PROPERTYKEY pkey_expect
;
352 {NULL
, NULL
, E_POINTER
},
353 {NULL
, &out
, E_POINTER
, {GUID_MEMBERS(dummy_guid
), 0xdeadbeef}},
354 {emptyW
, NULL
, E_POINTER
},
355 {emptyW
, &out
, E_INVALIDARG
, {GUID_MEMBERS(GUID_NULL
), 0}},
356 {fmtid_clsidW
, &out
, E_INVALIDARG
, {GUID_MEMBERS(GUID_NULL
), 0}},
357 {fmtid_truncatedW
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0,0,0,0,0,0,0,0}}, 0}},
358 {fmtid_nobracketsW
, &out
, E_INVALIDARG
, {GUID_MEMBERS(GUID_NULL
), 0}},
359 {fmtid_badbracketW
, &out
, E_INVALIDARG
, {GUID_MEMBERS(GUID_NULL
), 0}},
360 {fmtid_badcharW
, &out
, E_INVALIDARG
, {GUID_MEMBERS(GUID_NULL
), 0}},
361 {fmtid_badchar2W
, &out
, E_INVALIDARG
, {GUID_MEMBERS(GUID_NULL
), 0}},
362 {fmtid_baddashW
, &out
, E_INVALIDARG
, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
363 {fmtid_badchar3W
, &out
, E_INVALIDARG
, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
364 {fmtid_badchar4W
, &out
, E_INVALIDARG
, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
365 {fmtid_baddash2W
, &out
, E_INVALIDARG
, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
366 {fmtid_badchar5W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0,{0,0,0,0,0,0,0,0}}, 0}},
367 {fmtid_badchar6W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0,{0,0,0,0,0,0,0,0}}, 0}},
368 {fmtid_baddash3W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0,{0,0,0,0,0,0,0,0}}, 0}},
369 {fmtid_badchar7W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0,0,0,0,0,0,0,0}}, 0}},
370 {fmtid_badchar8W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0,0,0,0,0,0,0}}, 0}},
371 {fmtid_baddash4W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0,0,0,0,0,0,0}}, 0}},
372 {fmtid_badchar9W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0x34,0,0,0,0,0,0}}, 0}},
373 {fmtid_badchar9_adjW
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0x34,0,0,0,0,0,0}}, 0}},
374 {fmtid_badchar10W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0,0,0,0,0}}, 0}},
375 {fmtid_badchar11W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0,0,0,0}}, 0}},
376 {fmtid_badchar12W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0,0,0}}, 0}},
377 {fmtid_badchar13W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0,0}}, 0}},
378 {fmtid_badchar14W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0x90,0}}, 0}},
379 {fmtid_badbracket2W
, &out
, E_INVALIDARG
, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0x90,0x00}}, 0 }},
380 {fmtid_spaceW
, &out
, E_INVALIDARG
, {GUID_MEMBERS(GUID_NULL
), 0 }},
381 {fmtid_spaceendW
, &out
, E_INVALIDARG
, {GUID_MEMBERS(expect_guid
), 0}},
382 {fmtid_spacesendW
, &out
, E_INVALIDARG
, {GUID_MEMBERS(expect_guid
), 0}},
383 {fmtid_nopidW
, &out
, E_INVALIDARG
, {GUID_MEMBERS(expect_guid
), 0}},
384 {fmtid_badpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
385 {fmtid_adjpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
386 {fmtid_spacespidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
387 {fmtid_negpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
388 {fmtid_negnegpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 4294953717U}},
389 {fmtid_negnegnegpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
390 {fmtid_negspacepidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
391 {fmtid_negspacenegpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 4294953717U}},
392 {fmtid_negspacespidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
393 {fmtid_pospidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
394 {fmtid_posnegpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
395 {fmtid_symbolpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
396 {fmtid_letterpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
397 {fmtid_spacepadpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
398 {fmtid_spacemixpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 1}},
399 {fmtid_tabpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
400 {fmtid_hexpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
401 {fmtid_mixedpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
402 {fmtid_overflowpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 3755744309U}},
403 {fmtid_commapidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
404 {fmtid_commaspidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
405 {fmtid_commaspacepidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
406 {fmtid_spacecommapidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
407 {fmtid_spccommaspcpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
408 {fmtid_spacescommaspidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
409 {fmtid_commanegpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 4294953717U}},
410 {fmtid_spccommanegpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 4294953717U}},
411 {fmtid_commaspcnegpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 4294953717U}},
412 {fmtid_spccommaspcnegpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 4294953717U}},
413 {fmtid_commanegspcpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0U}},
414 {fmtid_negcommapidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 0}},
415 {fmtid_normalpidW
, &out
, S_OK
, {GUID_MEMBERS(expect_guid
), 13579}},
420 for (i
= 0; i
< sizeof(testcases
)/sizeof(testcases
[0]); i
++)
422 if (testcases
[i
].pkey
)
423 *testcases
[i
].pkey
= out_init
;
425 ret
= PSPropertyKeyFromString(testcases
[i
].pwzString
, testcases
[i
].pkey
);
426 ok(ret
== testcases
[i
].hr_expect
,
427 "[%d] Expected PSPropertyKeyFromString to return 0x%08x, got 0x%08x\n",
428 i
, testcases
[i
].hr_expect
, ret
);
430 if (testcases
[i
].pkey
)
432 ok(IsEqualGUID(&testcases
[i
].pkey
->fmtid
, &testcases
[i
].pkey_expect
.fmtid
),
433 "[%d] Expected GUID %s, got %s\n",
434 i
, wine_dbgstr_guid(&testcases
[i
].pkey_expect
.fmtid
), wine_dbgstr_guid(&testcases
[i
].pkey
->fmtid
));
435 ok(testcases
[i
].pkey
->pid
== testcases
[i
].pkey_expect
.pid
,
436 "[%d] Expected property ID %u, got %u\n",
437 i
, testcases
[i
].pkey_expect
.pid
, testcases
[i
].pkey
->pid
);
442 static void test_PSRefreshPropertySchema(void)
446 ret
= PSRefreshPropertySchema();
448 ok(ret
== CO_E_NOTINITIALIZED
,
449 "Expected PSRefreshPropertySchema to return CO_E_NOTINITIALIZED, got 0x%08x\n", ret
);
453 ret
= PSRefreshPropertySchema();
455 "Expected PSRefreshPropertySchema to return S_OK, got 0x%08x\n", ret
);
460 static void test_InitPropVariantFromGUIDAsString(void)
471 {&IID_NULL
, "{00000000-0000-0000-0000-000000000000}" },
472 {&dummy_guid
, "{DEADBEEF-DEAD-BEEF-DEAD-BEEFCAFEBABE}" },
475 hres
= InitPropVariantFromGUIDAsString(NULL
, &propvar
);
476 ok(hres
== E_FAIL
, "InitPropVariantFromGUIDAsString returned %x\n", hres
);
479 /* Returns strange data on Win7, crashes on older systems */
480 InitVariantFromGUIDAsString(NULL
, &var
);
482 /* Crashes on windows */
483 InitPropVariantFromGUIDAsString(&IID_NULL
, NULL
);
484 InitVariantFromGUIDAsString(&IID_NULL
, NULL
);
487 for(i
=0; i
<sizeof(testcases
)/sizeof(testcases
[0]); i
++) {
488 memset(&propvar
, 0, sizeof(PROPVARIANT
));
489 hres
= InitPropVariantFromGUIDAsString(testcases
[i
].guid
, &propvar
);
490 ok(hres
== S_OK
, "%d) InitPropVariantFromGUIDAsString returned %x\n", i
, hres
);
491 ok(propvar
.vt
== VT_LPWSTR
, "%d) propvar.vt = %d\n", i
, propvar
.vt
);
492 ok(!strcmp_wa(propvar
.u
.pwszVal
, testcases
[i
].str
), "%d) propvar.u.pwszVal = %s\n",
493 i
, wine_dbgstr_w(propvar
.u
.pwszVal
));
494 CoTaskMemFree(propvar
.u
.pwszVal
);
496 memset(&var
, 0, sizeof(VARIANT
));
497 hres
= InitVariantFromGUIDAsString(testcases
[i
].guid
, &var
);
498 ok(hres
== S_OK
, "%d) InitVariantFromGUIDAsString returned %x\n", i
, hres
);
499 ok(V_VT(&var
) == VT_BSTR
, "%d) V_VT(&var) = %d\n", i
, V_VT(&var
));
500 ok(SysStringLen(V_BSTR(&var
)) == 38, "SysStringLen returned %d\n",
501 SysStringLen(V_BSTR(&var
)));
502 ok(!strcmp_wa(V_BSTR(&var
), testcases
[i
].str
), "%d) V_BSTR(&var) = %s\n",
503 i
, wine_dbgstr_w(V_BSTR(&var
)));
508 static void test_InitPropVariantFromBuffer(void)
510 static const char data_in
[] = "test";
517 hres
= InitPropVariantFromBuffer(NULL
, 0, &propvar
);
518 ok(hres
== S_OK
, "InitPropVariantFromBuffer returned %x\n", hres
);
519 ok(propvar
.vt
== (VT_VECTOR
|VT_UI1
), "propvar.vt = %d\n", propvar
.vt
);
520 ok(propvar
.u
.caub
.cElems
== 0, "cElems = %d\n", propvar
.u
.caub
.cElems
== 0);
521 PropVariantClear(&propvar
);
523 hres
= InitPropVariantFromBuffer(data_in
, 4, &propvar
);
524 ok(hres
== S_OK
, "InitPropVariantFromBuffer returned %x\n", hres
);
525 ok(propvar
.vt
== (VT_VECTOR
|VT_UI1
), "propvar.vt = %d\n", propvar
.vt
);
526 ok(propvar
.u
.caub
.cElems
== 4, "cElems = %d\n", propvar
.u
.caub
.cElems
== 0);
527 ok(!memcmp(propvar
.u
.caub
.pElems
, data_in
, 4), "Data inside array is incorrect\n");
528 PropVariantClear(&propvar
);
530 hres
= InitVariantFromBuffer(NULL
, 0, &var
);
531 ok(hres
== S_OK
, "InitVariantFromBuffer returned %x\n", hres
);
532 ok(V_VT(&var
) == (VT_ARRAY
|VT_UI1
), "V_VT(&var) = %d\n", V_VT(&var
));
533 size
= SafeArrayGetDim(V_ARRAY(&var
));
534 ok(size
== 1, "SafeArrayGetDim returned %d\n", size
);
535 hres
= SafeArrayGetLBound(V_ARRAY(&var
), 1, &size
);
536 ok(hres
== S_OK
, "SafeArrayGetLBound returned %x\n", hres
);
537 ok(size
== 0, "LBound = %d\n", size
);
538 hres
= SafeArrayGetUBound(V_ARRAY(&var
), 1, &size
);
539 ok(hres
== S_OK
, "SafeArrayGetUBound returned %x\n", hres
);
540 ok(size
== -1, "UBound = %d\n", size
);
543 hres
= InitVariantFromBuffer(data_in
, 4, &var
);
544 ok(hres
== S_OK
, "InitVariantFromBuffer returned %x\n", hres
);
545 ok(V_VT(&var
) == (VT_ARRAY
|VT_UI1
), "V_VT(&var) = %d\n", V_VT(&var
));
546 size
= SafeArrayGetDim(V_ARRAY(&var
));
547 ok(size
== 1, "SafeArrayGetDim returned %d\n", size
);
548 hres
= SafeArrayGetLBound(V_ARRAY(&var
), 1, &size
);
549 ok(hres
== S_OK
, "SafeArrayGetLBound returned %x\n", hres
);
550 ok(size
== 0, "LBound = %d\n", size
);
551 hres
= SafeArrayGetUBound(V_ARRAY(&var
), 1, &size
);
552 ok(hres
== S_OK
, "SafeArrayGetUBound returned %x\n", hres
);
553 ok(size
== 3, "UBound = %d\n", size
);
554 hres
= SafeArrayAccessData(V_ARRAY(&var
), &data_out
);
555 ok(hres
== S_OK
, "SafeArrayAccessData failed %x\n", hres
);
556 ok(!memcmp(data_in
, data_out
, 4), "Data inside safe array is incorrect\n");
557 hres
= SafeArrayUnaccessData(V_ARRAY(&var
));
558 ok(hres
== S_OK
, "SafeArrayUnaccessData failed %x\n", hres
);
562 static void test_PropVariantToGUID(void)
569 hres
= InitPropVariantFromGUIDAsString(&IID_NULL
, &propvar
);
570 ok(hres
== S_OK
, "InitPropVariantFromGUIDAsString failed %x\n", hres
);
572 hres
= PropVariantToGUID(&propvar
, &guid
);
573 ok(hres
== S_OK
, "PropVariantToGUID failed %x\n", hres
);
574 ok(!memcmp(&IID_NULL
, &guid
, sizeof(GUID
)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid
));
575 PropVariantClear(&propvar
);
577 hres
= InitPropVariantFromGUIDAsString(&dummy_guid
, &propvar
);
578 ok(hres
== S_OK
, "InitPropVariantFromGUIDAsString failed %x\n", hres
);
580 hres
= PropVariantToGUID(&propvar
, &guid
);
581 ok(hres
== S_OK
, "PropVariantToGUID failed %x\n", hres
);
582 ok(!memcmp(&dummy_guid
, &guid
, sizeof(GUID
)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid
));
584 ok(propvar
.vt
== VT_LPWSTR
, "incorrect PROPVARIANT type: %d\n", propvar
.vt
);
585 propvar
.u
.pwszVal
[1] = 'd';
586 propvar
.u
.pwszVal
[2] = 'E';
587 propvar
.u
.pwszVal
[3] = 'a';
588 hres
= PropVariantToGUID(&propvar
, &guid
);
589 ok(hres
== S_OK
, "PropVariantToGUID failed %x\n", hres
);
590 ok(!memcmp(&dummy_guid
, &guid
, sizeof(GUID
)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid
));
592 propvar
.u
.pwszVal
[1] = 'z';
593 hres
= PropVariantToGUID(&propvar
, &guid
);
594 ok(hres
== E_INVALIDARG
, "PropVariantToGUID returned %x\n", hres
);
595 PropVariantClear(&propvar
);
598 hres
= InitVariantFromGUIDAsString(&IID_NULL
, &var
);
599 ok(hres
== S_OK
, "InitVariantFromGUIDAsString failed %x\n", hres
);
601 hres
= VariantToGUID(&var
, &guid
);
602 ok(hres
== S_OK
, "VariantToGUID failed %x\n", hres
);
603 ok(!memcmp(&IID_NULL
, &guid
, sizeof(GUID
)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid
));
606 hres
= InitVariantFromGUIDAsString(&dummy_guid
, &var
);
607 ok(hres
== S_OK
, "InitVariantFromGUIDAsString failed %x\n", hres
);
609 hres
= VariantToGUID(&var
, &guid
);
610 ok(hres
== S_OK
, "VariantToGUID failed %x\n", hres
);
611 ok(!memcmp(&dummy_guid
, &guid
, sizeof(GUID
)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid
));
613 ok(V_VT(&var
) == VT_BSTR
, "incorrect VARIANT type: %d\n", V_VT(&var
));
614 V_BSTR(&var
)[1] = 'z';
615 hres
= VariantToGUID(&var
, &guid
);
616 ok(hres
== E_FAIL
, "VariantToGUID returned %x\n", hres
);
618 V_BSTR(&var
)[1] = 'd';
619 propvar
.vt
= V_VT(&var
);
620 propvar
.u
.bstrVal
= V_BSTR(&var
);
621 V_VT(&var
) = VT_EMPTY
;
622 hres
= PropVariantToGUID(&propvar
, &guid
);
623 ok(hres
== S_OK
, "PropVariantToGUID failed %x\n", hres
);
624 ok(!memcmp(&dummy_guid
, &guid
, sizeof(GUID
)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid
));
625 PropVariantClear(&propvar
);
628 static void test_PropVariantCompare(void)
630 PROPVARIANT empty
, null
, emptyarray
, i2_0
, i2_2
, i4_large
, i4_largeneg
, i4_2
, str_2
, str_02
, str_b
;
632 static const WCHAR str_2W
[] = {'2', 0};
633 static const WCHAR str_02W
[] = {'0', '2', 0};
634 static const WCHAR str_bW
[] = {'b', 0};
635 SAFEARRAY emptysafearray
;
637 PropVariantInit(&empty
);
638 PropVariantInit(&null
);
639 PropVariantInit(&emptyarray
);
640 PropVariantInit(&i2_0
);
641 PropVariantInit(&i2_2
);
642 PropVariantInit(&i4_large
);
643 PropVariantInit(&i4_largeneg
);
644 PropVariantInit(&i4_2
);
645 PropVariantInit(&str_2
);
646 PropVariantInit(&str_b
);
650 emptyarray
.vt
= VT_ARRAY
| VT_I4
;
651 emptyarray
.u
.parray
= &emptysafearray
;
652 emptysafearray
.cDims
= 1;
653 emptysafearray
.fFeatures
= FADF_FIXEDSIZE
;
654 emptysafearray
.cbElements
= 4;
655 emptysafearray
.cLocks
= 0;
656 emptysafearray
.pvData
= NULL
;
657 emptysafearray
.rgsabound
[0].cElements
= 0;
658 emptysafearray
.rgsabound
[0].lLbound
= 0;
664 i4_large
.u
.lVal
= 65536;
665 i4_largeneg
.vt
= VT_I4
;
666 i4_largeneg
.u
.lVal
= -65536;
670 str_2
.u
.bstrVal
= SysAllocString(str_2W
);
672 str_02
.u
.bstrVal
= SysAllocString(str_02W
);
674 str_b
.u
.bstrVal
= SysAllocString(str_bW
);
676 res
= PropVariantCompareEx(&empty
, &empty
, 0, 0);
677 ok(res
== 0, "res=%i\n", res
);
679 res
= PropVariantCompareEx(&empty
, &null
, 0, 0);
680 ok(res
== 0, "res=%i\n", res
);
682 res
= PropVariantCompareEx(&null
, &emptyarray
, 0, 0);
683 ok(res
== 0, "res=%i\n", res
);
685 res
= PropVariantCompareEx(&null
, &i2_0
, 0, 0);
686 ok(res
== -1, "res=%i\n", res
);
688 res
= PropVariantCompareEx(&i2_0
, &null
, 0, 0);
689 ok(res
== 1, "res=%i\n", res
);
691 res
= PropVariantCompareEx(&null
, &i2_0
, 0, PVCF_TREATEMPTYASGREATERTHAN
);
692 ok(res
== 1, "res=%i\n", res
);
694 res
= PropVariantCompareEx(&i2_0
, &null
, 0, PVCF_TREATEMPTYASGREATERTHAN
);
695 ok(res
== -1, "res=%i\n", res
);
697 res
= PropVariantCompareEx(&i2_2
, &i2_0
, 0, 0);
698 ok(res
== 1, "res=%i\n", res
);
700 res
= PropVariantCompareEx(&i2_0
, &i2_2
, 0, 0);
701 ok(res
== -1, "res=%i\n", res
);
703 /* Always return -1 if second value cannot be converted to first type */
704 res
= PropVariantCompareEx(&i2_0
, &i4_large
, 0, 0);
705 ok(res
== -1, "res=%i\n", res
);
707 res
= PropVariantCompareEx(&i2_0
, &i4_largeneg
, 0, 0);
708 ok(res
== -1, "res=%i\n", res
);
710 res
= PropVariantCompareEx(&i4_large
, &i2_0
, 0, 0);
711 ok(res
== 1, "res=%i\n", res
);
713 res
= PropVariantCompareEx(&i4_largeneg
, &i2_0
, 0, 0);
714 ok(res
== -1, "res=%i\n", res
);
716 res
= PropVariantCompareEx(&i2_2
, &i4_2
, 0, 0);
717 ok(res
== 0, "res=%i\n", res
);
719 res
= PropVariantCompareEx(&i2_2
, &str_2
, 0, 0);
720 todo_wine
ok(res
== 0, "res=%i\n", res
);
722 res
= PropVariantCompareEx(&i2_2
, &str_02
, 0, 0);
723 todo_wine
ok(res
== 0, "res=%i\n", res
);
725 res
= PropVariantCompareEx(&str_2
, &i2_2
, 0, 0);
726 todo_wine
ok(res
== 0, "res=%i\n", res
);
728 res
= PropVariantCompareEx(&str_02
, &i2_2
, 0, 0);
729 ok(res
== -1, "res=%i\n", res
);
731 res
= PropVariantCompareEx(&str_02
, &str_2
, 0, 0);
732 ok(res
== -1, "res=%i\n", res
);
734 res
= PropVariantCompareEx(&str_02
, &str_b
, 0, 0);
735 ok(res
== -1, "res=%i\n", res
);
737 res
= PropVariantCompareEx(&str_2
, &str_02
, 0, 0);
738 ok(res
== 1, "res=%i\n", res
);
740 res
= PropVariantCompareEx(&i4_large
, &str_b
, 0, 0);
741 todo_wine
ok(res
== -5 /* ??? */, "res=%i\n", res
);
743 SysFreeString(str_2
.u
.bstrVal
);
744 SysFreeString(str_02
.u
.bstrVal
);
745 SysFreeString(str_b
.u
.bstrVal
);
748 static inline const char* debugstr_longlong(ULONGLONG ll
)
750 static char string
[17];
751 if (sizeof(ll
) > sizeof(unsigned long) && ll
>> 32)
752 sprintf(string
, "%lx%08lx", (unsigned long)(ll
>> 32), (unsigned long)ll
);
754 sprintf(string
, "%lx", (unsigned long)ll
);
758 static void test_intconversions(void)
770 hr
= PropVariantClear(&propvar
);
771 ok (FAILED(hr
), "PropVariantClear fails on invalid vt.\n");
774 PropVariantClear(&propvar
);
777 propvar
.u
.hVal
.QuadPart
= (LONGLONG
)1 << 63;
779 hr
= PropVariantToInt64(&propvar
, &llval
);
780 ok(hr
== S_OK
, "hr=%x\n", hr
);
781 ok(llval
== (LONGLONG
)1 << 63, "got wrong value %s\n", debugstr_longlong(llval
));
783 hr
= PropVariantToUInt64(&propvar
, &ullval
);
784 ok(hr
== HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW
), "hr=%x\n", hr
);
786 hr
= PropVariantToInt32(&propvar
, &lval
);
787 ok(hr
== HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW
), "hr=%x\n", hr
);
789 hr
= PropVariantToUInt32(&propvar
, &ulval
);
790 ok(hr
== HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW
), "hr=%x\n", hr
);
792 hr
= PropVariantToInt16(&propvar
, &sval
);
793 ok(hr
== HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW
), "hr=%x\n", hr
);
795 hr
= PropVariantToUInt16(&propvar
, &usval
);
796 ok(hr
== HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW
), "hr=%x\n", hr
);
799 propvar
.u
.uhVal
.QuadPart
= 5;
801 hr
= PropVariantToInt64(&propvar
, &llval
);
802 ok(hr
== S_OK
, "hr=%x\n", hr
);
803 ok(llval
== 5, "got wrong value %s\n", debugstr_longlong(llval
));
805 hr
= PropVariantToUInt64(&propvar
, &ullval
);
806 ok(hr
== S_OK
, "hr=%x\n", hr
);
807 ok(ullval
== 5, "got wrong value %s\n", debugstr_longlong(ullval
));
809 hr
= PropVariantToInt32(&propvar
, &lval
);
810 ok(hr
== S_OK
, "hr=%x\n", hr
);
811 ok(lval
== 5, "got wrong value %d\n", lval
);
813 hr
= PropVariantToUInt32(&propvar
, &ulval
);
814 ok(hr
== S_OK
, "hr=%x\n", hr
);
815 ok(ulval
== 5, "got wrong value %d\n", ulval
);
817 hr
= PropVariantToInt16(&propvar
, &sval
);
818 ok(hr
== S_OK
, "hr=%x\n", hr
);
819 ok(sval
== 5, "got wrong value %d\n", sval
);
821 hr
= PropVariantToUInt16(&propvar
, &usval
);
822 ok(hr
== S_OK
, "hr=%x\n", hr
);
823 ok(usval
== 5, "got wrong value %d\n", usval
);
826 propvar
.u
.hVal
.QuadPart
= -5;
828 hr
= PropVariantToInt64(&propvar
, &llval
);
829 ok(hr
== S_OK
, "hr=%x\n", hr
);
830 ok(llval
== -5, "got wrong value %s\n", debugstr_longlong(llval
));
832 hr
= PropVariantToUInt64(&propvar
, &ullval
);
833 ok(hr
== HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW
), "hr=%x\n", hr
);
835 hr
= PropVariantToInt32(&propvar
, &lval
);
836 ok(hr
== S_OK
, "hr=%x\n", hr
);
837 ok(lval
== -5, "got wrong value %d\n", lval
);
839 hr
= PropVariantToUInt32(&propvar
, &ulval
);
840 ok(hr
== HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW
), "hr=%x\n", hr
);
842 hr
= PropVariantToInt16(&propvar
, &sval
);
843 ok(hr
== S_OK
, "hr=%x\n", hr
);
844 ok(sval
== -5, "got wrong value %d\n", sval
);
846 hr
= PropVariantToUInt16(&propvar
, &usval
);
847 ok(hr
== HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW
), "hr=%x\n", hr
);
852 hr
= PropVariantToInt64(&propvar
, &llval
);
853 ok(hr
== S_OK
, "hr=%x\n", hr
);
854 ok(llval
== 6, "got wrong value %s\n", debugstr_longlong(llval
));
859 hr
= PropVariantToInt64(&propvar
, &llval
);
860 ok(hr
== S_OK
, "hr=%x\n", hr
);
861 ok(llval
== -6, "got wrong value %s\n", debugstr_longlong(llval
));
866 hr
= PropVariantToInt64(&propvar
, &llval
);
867 ok(hr
== S_OK
, "hr=%x\n", hr
);
868 ok(llval
== 7, "got wrong value %s\n", debugstr_longlong(llval
));
873 hr
= PropVariantToInt64(&propvar
, &llval
);
874 ok(hr
== S_OK
, "hr=%x\n", hr
);
875 ok(llval
== -7, "got wrong value %s\n", debugstr_longlong(llval
));
880 test_PSStringFromPropertyKey();
881 test_PSPropertyKeyFromString();
882 test_PSRefreshPropertySchema();
883 test_InitPropVariantFromGUIDAsString();
884 test_InitPropVariantFromBuffer();
885 test_PropVariantToGUID();
886 test_PropVariantCompare();
887 test_intconversions();