Release 1.3.7.
[wine/gsoc-2012-control.git] / dlls / propsys / tests / propsys.c
blobd734029149d63082ff5a958199691326ba8331c6
1 /*
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 COBJMACROS
24 #include <stdarg.h>
25 #include <stdio.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "objbase.h"
30 #include "propsys.h"
31 #include "initguid.h"
32 #include "wine/test.h"
34 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
35 DEFINE_GUID(dummy_guid, 0xdeadbeef, 0xdead, 0xbeef, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe);
36 DEFINE_GUID(expect_guid, 0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12);
38 static char *show_guid(const GUID *guid, char *buf)
40 sprintf(buf,
41 "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
42 guid->Data1, guid->Data2, guid->Data3,
43 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
44 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
46 return buf;
49 static void test_PSStringFromPropertyKey(void)
51 static const WCHAR fillerW[] = {'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
52 'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
53 'X','X','X','X','X','X','X','X','X','X'};
54 static const WCHAR zero_fillerW[] = {'\0','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
55 'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
56 'X','X','X','X','X','X','X','X','X','X','X','X','X','X'};
57 static const WCHAR zero_truncatedW[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
58 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
59 '0','0','0','}',' ','\0','9','X','X','X','X','X','X','X','X','X'};
60 static const WCHAR zero_truncated2W[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
61 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
62 '0','0','0','}',' ','\0','9','2','7','6','9','4','9','2','X','X'};
63 static const WCHAR zero_truncated3W[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
64 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
65 '0','0','0','}',' ','\0','9','2','7','6','9','4','9','2','4','X'};
66 static const WCHAR zero_truncated4W[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
67 '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
68 '0','0','0','}',' ','\0','7','X','X','X','X','X','X','X','X','X'};
69 static const WCHAR truncatedW[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
70 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
71 '0','}',' ','\0','9','X','X','X','X','X','X','X','X','X'};
72 static const WCHAR truncated2W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
73 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
74 '0','}',' ','\0','9','2','7','6','9','4','9','2','X','X'};
75 static const WCHAR truncated3W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
76 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
77 '0','}',' ','\0','9','2','7','6','9','4','9','2','4','X'};
78 static const WCHAR truncated4W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
79 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
80 '0','}',' ','\0','7','X','X','X','X','X','X','X','X','X'};
81 static const WCHAR expectedW[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
82 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
83 '0','}',' ','4','2','9','4','9','6','7','2','9','5',0};
84 static const WCHAR expected2W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
85 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
86 '0','}',' ','1','3','5','7','9','\0','X','X','X','X','X'};
87 static const WCHAR expected3W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
88 '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
89 '0','}',' ','0','\0','X','X','X','X','X','X','X','X','X'};
90 PROPERTYKEY prop = {GUID_NULL, ~0U};
91 PROPERTYKEY prop2 = {GUID_NULL, 13579};
92 PROPERTYKEY prop3 = {GUID_NULL, 0};
93 WCHAR out[PKEYSTR_MAX];
94 HRESULT ret;
96 const struct
98 REFPROPERTYKEY pkey;
99 LPWSTR psz;
100 UINT cch;
101 HRESULT hr_expect;
102 const WCHAR *buf_expect;
103 int hr_broken;
104 HRESULT hr2;
105 int buf_broken;
106 const WCHAR *buf2;
107 } testcases[] =
109 {NULL, NULL, 0, E_POINTER},
110 {&prop, NULL, 0, E_POINTER},
111 {&prop, NULL, PKEYSTR_MAX, E_POINTER},
112 {NULL, out, 0, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
113 {NULL, out, PKEYSTR_MAX, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_fillerW, 0, 0, 1, fillerW},
114 {&prop, out, 0, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
115 {&prop, out, GUIDSTRING_MAX, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
116 {&prop, out, GUIDSTRING_MAX + 1, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
117 {&prop, out, GUIDSTRING_MAX + 2, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_truncatedW, 1, S_OK, 1, truncatedW},
118 {&prop, out, PKEYSTR_MAX - 2, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_truncated2W, 1, S_OK, 1, truncated2W},
119 {&prop, out, PKEYSTR_MAX - 1, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_truncated3W, 1, S_OK, 1, truncated3W},
120 {&prop, out, PKEYSTR_MAX, S_OK, expectedW},
121 {&prop2, out, GUIDSTRING_MAX + 2, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_truncated4W, 1, S_OK, 1, truncated4W},
122 {&prop2, out, GUIDSTRING_MAX + 6, S_OK, expected2W},
123 {&prop2, out, PKEYSTR_MAX, S_OK, expected2W},
124 {&prop3, out, GUIDSTRING_MAX + 1, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
125 {&prop3, out, GUIDSTRING_MAX + 2, S_OK, expected3W},
126 {&prop3, out, PKEYSTR_MAX, S_OK, expected3W},
129 int i;
131 for (i = 0; i < sizeof(testcases)/sizeof(testcases[0]); i++)
133 if (testcases[i].psz)
134 memcpy(testcases[i].psz, fillerW, PKEYSTR_MAX * sizeof(WCHAR));
136 ret = PSStringFromPropertyKey(testcases[i].pkey,
137 testcases[i].psz,
138 testcases[i].cch);
139 ok(ret == testcases[i].hr_expect ||
140 broken(testcases[i].hr_broken && ret == testcases[i].hr2), /* Vista/Win2k8 */
141 "[%d] Expected PSStringFromPropertyKey to return 0x%08x, got 0x%08x\n",
142 i, testcases[i].hr_expect, ret);
144 if (testcases[i].psz)
145 ok(!memcmp(testcases[i].psz, testcases[i].buf_expect, PKEYSTR_MAX * sizeof(WCHAR)) ||
146 broken(testcases[i].buf_broken &&
147 !memcmp(testcases[i].psz, testcases[i].buf2, PKEYSTR_MAX * sizeof(WCHAR))), /* Vista/Win2k8 */
148 "[%d] Unexpected output contents\n", i);
152 static void test_PSPropertyKeyFromString(void)
154 static const WCHAR emptyW[] = {0};
155 static const WCHAR fmtid_clsidW[] = {'S','t','d','F','o','n','t',' ','1',0};
156 static const WCHAR fmtid_truncatedW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
157 '1','2','3','4','-',0};
158 static const WCHAR fmtid_nobracketsW[] = {'1','2','3','4','5','6','7','8','-','1','2','3','4','-',
159 '1','2','3','4','-','1','2','3','4','-',
160 '1','2','3','4','5','6','7','8','9','0','1','2',0};
161 static const WCHAR fmtid_badbracketW[] = {'X','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
162 '1','2','3','4','-','1','2','3','4','-',
163 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
164 static const WCHAR fmtid_badcharW[] = {'{','X','2','3','4','5','6','7','8','-','1','2','3','4','-',
165 '1','2','3','4','-','1','2','3','4','-',
166 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
167 static const WCHAR fmtid_badchar2W[] = {'{','1','2','3','4','5','6','7','X','-','1','2','3','4','-',
168 '1','2','3','4','-','1','2','3','4','-',
169 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
170 static const WCHAR fmtid_baddashW[] = {'{','1','2','3','4','5','6','7','8','X','1','2','3','4','-',
171 '1','2','3','4','-','1','2','3','4','-',
172 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
173 static const WCHAR fmtid_badchar3W[] = {'{','1','2','3','4','5','6','7','8','-','X','2','3','4','-',
174 '1','2','3','4','-','1','2','3','4','-',
175 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
176 static const WCHAR fmtid_badchar4W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','X','-',
177 '1','2','3','4','-','1','2','3','4','-',
178 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
179 static const WCHAR fmtid_baddash2W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','X',
180 '1','2','3','4','-','1','2','3','4','-',
181 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
182 static const WCHAR fmtid_badchar5W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
183 'X','2','3','4','-','1','2','3','4','-',
184 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
185 static const WCHAR fmtid_badchar6W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
186 '1','2','3','X','-','1','2','3','4','-',
187 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
188 static const WCHAR fmtid_baddash3W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
189 '1','2','3','4','X','1','2','3','4','-',
190 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
191 static const WCHAR fmtid_badchar7W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
192 '1','2','3','4','-','X','2','3','4','-',
193 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
194 static const WCHAR fmtid_badchar8W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
195 '1','2','3','4','-','1','2','3','X','-',
196 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
197 static const WCHAR fmtid_baddash4W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
198 '1','2','3','4','-','1','2','3','4','X',
199 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
200 static const WCHAR fmtid_badchar9W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
201 '1','2','3','4','-','1','2','3','4','-',
202 'X','2','3','4','5','6','7','8','9','0','1','2','}',0};
203 static const WCHAR fmtid_badchar9_adjW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
204 '1','2','3','4','-','1','2','3','4','-',
205 '1','X','3','4','5','6','7','8','9','0','1','2','}',0};
206 static const WCHAR fmtid_badchar10W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
207 '1','2','3','4','-','1','2','3','4','-',
208 '1','2','X','4','5','6','7','8','9','0','1','2','}',0};
209 static const WCHAR fmtid_badchar11W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
210 '1','2','3','4','-','1','2','3','4','-',
211 '1','2','3','4','X','6','7','8','9','0','1','2','}',0};
212 static const WCHAR fmtid_badchar12W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
213 '1','2','3','4','-','1','2','3','4','-',
214 '1','2','3','4','5','6','X','8','9','0','1','2','}',0};
215 static const WCHAR fmtid_badchar13W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
216 '1','2','3','4','-','1','2','3','4','-',
217 '1','2','3','4','5','6','7','8','X','0','1','2','}',0};
218 static const WCHAR fmtid_badchar14W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
219 '1','2','3','4','-','1','2','3','4','-',
220 '1','2','3','4','5','6','7','8','9','0','X','2','}',0};
221 static const WCHAR fmtid_badbracket2W[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
222 '1','2','3','4','-','1','2','3','4','-',
223 '1','2','3','4','5','6','7','8','9','0','1','2','X',0};
224 static const WCHAR fmtid_spaceW[] = {' ','{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
225 '1','2','3','4','-','1','2','3','4','-',
226 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
227 static const WCHAR fmtid_spaceendW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
228 '1','2','3','4','-','1','2','3','4','-',
229 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',0};
230 static const WCHAR fmtid_spacesendW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
231 '1','2','3','4','-','1','2','3','4','-',
232 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',' ',' ',0};
233 static const WCHAR fmtid_nopidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
234 '1','2','3','4','-','1','2','3','4','-',
235 '1','2','3','4','5','6','7','8','9','0','1','2','}',0};
236 static const WCHAR fmtid_badpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
237 '1','2','3','4','-','1','2','3','4','-',
238 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','D','E','A','D',0};
239 static const WCHAR fmtid_adjpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
240 '1','2','3','4','-','1','2','3','4','-',
241 '1','2','3','4','5','6','7','8','9','0','1','2','}','1','3','5','7','9',0};
242 static const WCHAR fmtid_spacespidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
243 '1','2','3','4','-','1','2','3','4','-',
244 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',' ',' ','1','3','5','7','9',0};
245 static const WCHAR fmtid_negpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
246 '1','2','3','4','-','1','2','3','4','-',
247 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-','1','3','5','7','9',0};
248 static const WCHAR fmtid_negnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
249 '1','2','3','4','-','1','2','3','4','-',
250 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-','-','1','3','5','7','9',0};
251 static const WCHAR fmtid_negnegnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
252 '1','2','3','4','-','1','2','3','4','-',
253 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-','-','-','1','3','5','7','9',0};
254 static const WCHAR fmtid_negspacepidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
255 '1','2','3','4','-','1','2','3','4','-',
256 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-',' ','1','3','5','7','9',0};
257 static const WCHAR fmtid_negspacenegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
258 '1','2','3','4','-','1','2','3','4','-',
259 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-',' ','-','1','3','5','7','9',0};
260 static const WCHAR fmtid_negspacespidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
261 '1','2','3','4','-','1','2','3','4','-',
262 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','-',' ','-',' ','-','1','3','5','7','9',0};
263 static const WCHAR fmtid_pospidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
264 '1','2','3','4','-','1','2','3','4','-',
265 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','+','1','3','5','7','9',0};
266 static const WCHAR fmtid_posnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
267 '1','2','3','4','-','1','2','3','4','-',
268 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','+','-','+','-','1','3','5','7','9',0};
269 static const WCHAR fmtid_symbolpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
270 '1','2','3','4','-','1','2','3','4','-',
271 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','+','/','$','-','1','3','5','7','9',0};
272 static const WCHAR fmtid_letterpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
273 '1','2','3','4','-','1','2','3','4','-',
274 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','A','B','C','D','1','3','5','7','9',0};
275 static const WCHAR fmtid_spacepadpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
276 '1','2','3','4','-','1','2','3','4','-',
277 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',' ',' ',' ',0};
278 static const WCHAR fmtid_spacemixpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
279 '1','2','3','4','-','1','2','3','4','-',
280 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1',' ','3',' ','5','7','9',' ',' ',' ',0};
281 static const WCHAR fmtid_tabpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
282 '1','2','3','4','-','1','2','3','4','-',
283 '1','2','3','4','5','6','7','8','9','0','1','2','}','\t','1','3','5','7','9',0};
284 static const WCHAR fmtid_hexpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
285 '1','2','3','4','-','1','2','3','4','-',
286 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','0','x','D','E','A','D',0};
287 static const WCHAR fmtid_mixedpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
288 '1','2','3','4','-','1','2','3','4','-',
289 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','A','9','B','5','C','3','D','1',0};
290 static const WCHAR fmtid_overflowpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
291 '1','2','3','4','-','1','2','3','4','-',
292 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','2','3','4','5','6','7','8','9','0','1',0};
293 static const WCHAR fmtid_commapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
294 '1','2','3','4','-','1','2','3','4','-',
295 '1','2','3','4','5','6','7','8','9','0','1','2','}',',','1','3','5','7','9',0};
296 static const WCHAR fmtid_commaspidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
297 '1','2','3','4','-','1','2','3','4','-',
298 '1','2','3','4','5','6','7','8','9','0','1','2','}',',',',',',','1','3','5','7','9',0};
299 static const WCHAR fmtid_commaspacepidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
300 '1','2','3','4','-','1','2','3','4','-',
301 '1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','1','3','5','7','9',0};
302 static const WCHAR fmtid_spacecommapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
303 '1','2','3','4','-','1','2','3','4','-',
304 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','1','3','5','7','9',0};
305 static const WCHAR fmtid_spccommaspcpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
306 '1','2','3','4','-','1','2','3','4','-',
307 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','1','3','5','7','9',0};
308 static const WCHAR fmtid_spacescommaspidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
309 '1','2','3','4','-','1','2','3','4','-',
310 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ',',','1','3','5','7','9',0};
311 static const WCHAR fmtid_commanegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
312 '1','2','3','4','-','1','2','3','4','-',
313 '1','2','3','4','5','6','7','8','9','0','1','2','}',',','-','1','3','5','7','9',0};
314 static const WCHAR fmtid_spccommanegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
315 '1','2','3','4','-','1','2','3','4','-',
316 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','-','1','3','5','7','9',0};
317 static const WCHAR fmtid_commaspcnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
318 '1','2','3','4','-','1','2','3','4','-',
319 '1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','-','1','3','5','7','9',0};
320 static const WCHAR fmtid_spccommaspcnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
321 '1','2','3','4','-','1','2','3','4','-',
322 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','-','1','3','5','7','9',0};
323 static const WCHAR fmtid_commanegspcpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
324 '1','2','3','4','-','1','2','3','4','-',
325 '1','2','3','4','5','6','7','8','9','0','1','2','}',',','-',' ','1','3','5','7','9',0};
326 static const WCHAR fmtid_negcommapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
327 '1','2','3','4','-','1','2','3','4','-',
328 '1','2','3','4','5','6','7','8','9','0','1','2','}','-',',','1','3','5','7','9',0};
329 static const WCHAR fmtid_normalpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
330 '1','2','3','4','-','1','2','3','4','-',
331 '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',0};
332 PROPERTYKEY out_init = {dummy_guid, 0xdeadbeef};
333 PROPERTYKEY out;
334 HRESULT ret;
335 char guid_buf[40], guid_buf2[40];
337 const struct
339 LPCWSTR pwzString;
340 PROPERTYKEY *pkey;
341 HRESULT hr_expect;
342 PROPERTYKEY pkey_expect;
343 } testcases[] =
345 {NULL, NULL, E_POINTER},
346 {NULL, &out, E_POINTER, out_init},
347 {emptyW, NULL, E_POINTER},
348 {emptyW, &out, E_INVALIDARG, {GUID_NULL, 0}},
349 {fmtid_clsidW, &out, E_INVALIDARG, {GUID_NULL, 0}},
350 {fmtid_truncatedW, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0,0,0,0,0,0,0,0}}, 0}},
351 {fmtid_nobracketsW, &out, E_INVALIDARG, {GUID_NULL, 0}},
352 {fmtid_badbracketW, &out, E_INVALIDARG, {GUID_NULL, 0}},
353 {fmtid_badcharW, &out, E_INVALIDARG, {GUID_NULL, 0}},
354 {fmtid_badchar2W, &out, E_INVALIDARG, {GUID_NULL, 0}},
355 {fmtid_baddashW, &out, E_INVALIDARG, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
356 {fmtid_badchar3W, &out, E_INVALIDARG, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
357 {fmtid_badchar4W, &out, E_INVALIDARG, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
358 {fmtid_baddash2W, &out, E_INVALIDARG, { {0x12345678,0,0,{0,0,0,0,0,0,0,0}}, 0}},
359 {fmtid_badchar5W, &out, E_INVALIDARG, { {0x12345678,0x1234,0,{0,0,0,0,0,0,0,0}}, 0}},
360 {fmtid_badchar6W, &out, E_INVALIDARG, { {0x12345678,0x1234,0,{0,0,0,0,0,0,0,0}}, 0}},
361 {fmtid_baddash3W, &out, E_INVALIDARG, { {0x12345678,0x1234,0,{0,0,0,0,0,0,0,0}}, 0}},
362 {fmtid_badchar7W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0,0,0,0,0,0,0,0}}, 0}},
363 {fmtid_badchar8W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0,0,0,0,0,0,0}}, 0}},
364 {fmtid_baddash4W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0,0,0,0,0,0,0}}, 0}},
365 {fmtid_badchar9W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0,0,0,0,0,0}}, 0}},
366 {fmtid_badchar9_adjW, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0,0,0,0,0,0}}, 0}},
367 {fmtid_badchar10W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0,0,0,0,0}}, 0}},
368 {fmtid_badchar11W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0,0,0,0}}, 0}},
369 {fmtid_badchar12W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0,0,0}}, 0}},
370 {fmtid_badchar13W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0,0}}, 0}},
371 {fmtid_badchar14W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0x90,0}}, 0}},
372 {fmtid_badbracket2W, &out, E_INVALIDARG, { {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0x90,0x00}}, 0 }},
373 {fmtid_spaceW, &out, E_INVALIDARG, {GUID_NULL, 0 }},
374 {fmtid_spaceendW, &out, E_INVALIDARG, {expect_guid, 0}},
375 {fmtid_spacesendW, &out, E_INVALIDARG, {expect_guid, 0}},
376 {fmtid_nopidW, &out, E_INVALIDARG, {expect_guid, 0}},
377 {fmtid_badpidW, &out, S_OK, {expect_guid, 0}},
378 {fmtid_adjpidW, &out, S_OK, {expect_guid, 13579}},
379 {fmtid_spacespidW, &out, S_OK, {expect_guid, 13579}},
380 {fmtid_negpidW, &out, S_OK, {expect_guid, 13579}},
381 {fmtid_negnegpidW, &out, S_OK, {expect_guid, 4294953717U}},
382 {fmtid_negnegnegpidW, &out, S_OK, {expect_guid, 0}},
383 {fmtid_negspacepidW, &out, S_OK, {expect_guid, 13579}},
384 {fmtid_negspacenegpidW, &out, S_OK, {expect_guid, 4294953717U}},
385 {fmtid_negspacespidW, &out, S_OK, {expect_guid, 0}},
386 {fmtid_pospidW, &out, S_OK, {expect_guid, 0}},
387 {fmtid_posnegpidW, &out, S_OK, {expect_guid, 0}},
388 {fmtid_symbolpidW, &out, S_OK, {expect_guid, 0}},
389 {fmtid_letterpidW, &out, S_OK, {expect_guid, 0}},
390 {fmtid_spacepadpidW, &out, S_OK, {expect_guid, 13579}},
391 {fmtid_spacemixpidW, &out, S_OK, {expect_guid, 1}},
392 {fmtid_tabpidW, &out, S_OK, {expect_guid, 0}},
393 {fmtid_hexpidW, &out, S_OK, {expect_guid, 0}},
394 {fmtid_mixedpidW, &out, S_OK, {expect_guid, 0}},
395 {fmtid_overflowpidW, &out, S_OK, {expect_guid, 3755744309U}},
396 {fmtid_commapidW, &out, S_OK, {expect_guid, 13579}},
397 {fmtid_commaspidW, &out, S_OK, {expect_guid, 0}},
398 {fmtid_commaspacepidW, &out, S_OK, {expect_guid, 13579}},
399 {fmtid_spacecommapidW, &out, S_OK, {expect_guid, 13579}},
400 {fmtid_spccommaspcpidW, &out, S_OK, {expect_guid, 13579}},
401 {fmtid_spacescommaspidW, &out, S_OK, {expect_guid, 0}},
402 {fmtid_commanegpidW, &out, S_OK, {expect_guid, 4294953717U}},
403 {fmtid_spccommanegpidW, &out, S_OK, {expect_guid, 4294953717U}},
404 {fmtid_commaspcnegpidW, &out, S_OK, {expect_guid, 4294953717U}},
405 {fmtid_spccommaspcnegpidW, &out, S_OK, {expect_guid, 4294953717U}},
406 {fmtid_commanegspcpidW, &out, S_OK, {expect_guid, 0U}},
407 {fmtid_negcommapidW, &out, S_OK, {expect_guid, 0}},
408 {fmtid_normalpidW, &out, S_OK, {expect_guid, 13579}},
411 int i;
413 for (i = 0; i < sizeof(testcases)/sizeof(testcases[0]); i++)
415 if (testcases[i].pkey)
416 *testcases[i].pkey = out_init;
418 ret = PSPropertyKeyFromString(testcases[i].pwzString, testcases[i].pkey);
419 ok(ret == testcases[i].hr_expect,
420 "[%d] Expected PSPropertyKeyFromString to return 0x%08x, got 0x%08x\n",
421 i, testcases[i].hr_expect, ret);
423 if (testcases[i].pkey)
425 ok(IsEqualGUID(&testcases[i].pkey->fmtid, &testcases[i].pkey_expect.fmtid),
426 "[%d] Expected GUID %s, got %s\n",
427 i, show_guid(&testcases[i].pkey_expect.fmtid, guid_buf), show_guid(&testcases[i].pkey->fmtid, guid_buf2));
428 ok(testcases[i].pkey->pid == testcases[i].pkey_expect.pid,
429 "[%d] Expected property ID %u, got %u\n",
430 i, testcases[i].pkey_expect.pid, testcases[i].pkey->pid);
435 START_TEST(propsys)
437 test_PSStringFromPropertyKey();
438 test_PSPropertyKeyFromString();