[MSI_WINETEST] Sync with Wine 3.0. CORE-14225
[reactos.git] / modules / rostests / winetests / msi / format.c
1 /*
2 * Copyright (C) 2005 Mike McCormack for CodeWeavers
3 * Copyright (C) 2005 Aric Stewart for CodeWeavers
4 *
5 * A test program for MSI record formatting
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #include "precomp.h"
23
24 static const char msifile[] = "winetest-format.msi";
25
26 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
27 {
28 UINT res;
29 CHAR szPackage[12];
30 MSIHANDLE hPackage;
31
32 sprintf(szPackage, "#%u", hdb);
33 res = MsiOpenPackageA(szPackage, &hPackage);
34 if (res != ERROR_SUCCESS)
35 return res;
36
37 res = MsiCloseHandle(hdb);
38 if (res != ERROR_SUCCESS)
39 {
40 MsiCloseHandle(hPackage);
41 return res;
42 }
43
44 *handle = hPackage;
45 return ERROR_SUCCESS;
46 }
47
48 static UINT helper_createpackage( const char *szName, MSIHANDLE *handle )
49 {
50 MSIHANDLE hPackage, suminfo, hdb = 0;
51 UINT res;
52 WCHAR *nameW;
53 int len;
54
55 DeleteFileA(szName);
56
57 len = MultiByteToWideChar( CP_ACP, 0, szName, -1, NULL, 0 );
58 if (!(nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
59 return ERROR_OUTOFMEMORY;
60 MultiByteToWideChar( CP_ACP, 0, szName, -1, nameW, len );
61
62 /* create an empty database */
63 res = MsiOpenDatabaseW( nameW, MSIDBOPEN_CREATEDIRECT, &hdb );
64 HeapFree( GetProcessHeap(), 0, nameW );
65 ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
66 if (res != ERROR_SUCCESS)
67 return res;
68
69 res = MsiDatabaseCommit( hdb );
70 ok( res == ERROR_SUCCESS , "Failed to commit database %u\n", res );
71
72 /* build summary info */
73 res = MsiGetSummaryInformationA(hdb, NULL, 7, &suminfo);
74 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
75
76 res = MsiSummaryInfoSetPropertyA(suminfo,2, VT_LPSTR, 0,NULL,
77 "Installation Database");
78 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
79
80 res = MsiSummaryInfoSetPropertyA(suminfo,3, VT_LPSTR, 0,NULL,
81 "Installation Database");
82 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
83
84 res = MsiSummaryInfoSetPropertyA(suminfo,4, VT_LPSTR, 0,NULL,
85 "Wine Hackers");
86 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
87
88 res = MsiSummaryInfoSetPropertyA(suminfo,7, VT_LPSTR, 0,NULL,
89 ";1033");
90 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
91
92 res = MsiSummaryInfoSetPropertyA(suminfo,9, VT_LPSTR, 0,NULL,
93 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
94 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
95
96 res = MsiSummaryInfoSetPropertyA(suminfo, 14, VT_I4, 100, NULL, NULL);
97 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
98
99 res = MsiSummaryInfoSetPropertyA(suminfo, 15, VT_I4, 0, NULL, NULL);
100 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
101
102 res = MsiSummaryInfoPersist(suminfo);
103 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
104
105 res = MsiCloseHandle( suminfo);
106 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
107
108 res = package_from_db( hdb, &hPackage );
109 MsiCloseHandle(hdb);
110
111 if (res != ERROR_SUCCESS)
112 DeleteFileA( szName );
113 else
114 *handle = hPackage;
115
116 return res;
117 }
118
119 static void test_createpackage(void)
120 {
121 MSIHANDLE hPackage = 0;
122 UINT res;
123
124 res = helper_createpackage( msifile, &hPackage );
125 if (res == ERROR_INSTALL_PACKAGE_REJECTED)
126 {
127 skip("Not enough rights to perform tests\n");
128 return;
129 }
130 ok( res == ERROR_SUCCESS, "Failed to create package %u\n", res );
131
132 res = MsiCloseHandle( hPackage );
133 ok( res == ERROR_SUCCESS , "Failed to close package %u\n", res );
134
135 DeleteFileA( msifile );
136 }
137
138 static void test_formatrecord(void)
139 {
140 char buffer[100];
141 MSIHANDLE hrec;
142 UINT r;
143 DWORD sz;
144
145 r = MsiFormatRecordA(0, 0, NULL, NULL );
146 ok( r == ERROR_INVALID_HANDLE, "wrong error\n");
147
148 hrec = MsiCreateRecord(0);
149 ok( hrec, "failed to create record\n");
150
151 /* format an empty record on a record with no parameters */
152 sz = sizeof(buffer);
153 r = MsiFormatRecordA(0, hrec, buffer, &sz );
154 ok( r == ERROR_SUCCESS, "format failed\n");
155 ok( sz == 0, "size wrong\n");
156
157 MsiCloseHandle( hrec );
158
159 hrec = MsiCreateRecord(4);
160 ok( hrec, "failed to create record\n");
161
162 /* format an empty record */
163 r = MsiFormatRecordA(0, hrec, NULL, NULL );
164 ok( r == ERROR_SUCCESS, "format failed\n");
165 buffer[0] = 'x';
166 buffer[1] = 0;
167 sz=0;
168 r = MsiFormatRecordA(0, hrec, buffer+1, &sz);
169 ok( r == ERROR_MORE_DATA && buffer[0] == 'x', "format failed measuring with buffer\n");
170 ok( sz == 16, "size wrong\n");
171 sz=100;
172 r = MsiFormatRecordA(0, hrec, buffer, &sz);
173 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
174 ok( sz == 16, "size wrong\n");
175 ok( 0 == strcmp(buffer,"1: 2: 3: 4: "), "wrong output\n");
176
177 r = MsiCloseHandle(hrec);
178 ok(r==ERROR_SUCCESS, "Unable to close record\n");
179
180 hrec = MsiCreateRecord(6);
181 ok( hrec, "failed to create record\n");
182
183 sz = 100;
184 buffer[0] = 'x';
185 buffer[1] = 0;
186 r = MsiFormatRecordA(0, hrec, buffer, &sz);
187 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
188 ok( sz == 24, "size wrong\n");
189 ok( 0 == strcmp(buffer,"1: 2: 3: 4: 5: 6: "), "wrong output\n");
190
191
192 /* format a format string with everything else empty */
193 r = MsiRecordSetStringA(hrec, 0, "%1");
194 ok( r == ERROR_SUCCESS, "set string failed\n");
195 r = MsiFormatRecordA(0, hrec, NULL, NULL );
196 ok( r == ERROR_SUCCESS, "format failed\n");
197 r = MsiFormatRecordA(0, hrec, buffer, NULL);
198 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
199
200 sz = 123;
201 r = MsiFormatRecordA(0, hrec, NULL, &sz);
202 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
203 ok( sz == 2, "size wrong (%i)\n",sz);
204 sz = sizeof buffer;
205 buffer[0] = 'x';
206 buffer[1] = 0;
207 r = MsiFormatRecordA(0, hrec, buffer, &sz);
208 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
209 ok( sz == 2, "size wrong\n");
210 ok( 0 == strcmp(buffer,"%1"), "wrong output\n");
211
212 /* make the buffer too small */
213 sz = 0;
214 buffer[0] = 'x';
215 buffer[1] = 0;
216 r = MsiFormatRecordA(0, hrec, buffer, &sz);
217 ok( r == ERROR_MORE_DATA, "format failed with empty buffer\n");
218 ok( sz == 2, "size wrong\n");
219 ok( 0 == strcmp(buffer,"x"), "wrong output\n");
220
221 /* make the buffer a little bit bigger */
222 sz = 1;
223 buffer[0] = 'x';
224 buffer[1] = 0;
225 r = MsiFormatRecordA(0, hrec, buffer, &sz);
226 ok( r == ERROR_MORE_DATA, "format failed with empty buffer\n");
227 ok( sz == 2, "size wrong\n");
228 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
229
230 /* and again */
231 sz = 2;
232 buffer[0] = 'x';
233 buffer[1] = 0;
234 r = MsiFormatRecordA(0, hrec, buffer, &sz);
235 ok( r == ERROR_MORE_DATA, "format failed with empty buffer\n");
236 ok( sz == 2, "size wrong\n");
237 ok( 0 == strcmp(buffer,"%"), "wrong output\n");
238
239 /* and again */
240 sz = 3;
241 buffer[0] = 'x';
242 buffer[1] = 0;
243 r = MsiFormatRecordA(0, hrec, buffer, &sz);
244 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
245 ok( sz == 2, "size wrong\n");
246 ok( 0 == strcmp(buffer,"%1"), "wrong output\n");
247
248 /* now try a real format string */
249 r = MsiRecordSetStringA(hrec, 0, "[1]");
250 ok( r == ERROR_SUCCESS, "set string failed\n");
251 sz = sizeof buffer;
252 r = MsiFormatRecordA(0, hrec, buffer, &sz);
253 ok( r == ERROR_SUCCESS, "format failed\n");
254 ok( sz == 0, "size wrong\n");
255 ok( 0 == strcmp(buffer,""), "wrong output\n");
256
257 /* now put something in the first field */
258 r = MsiRecordSetStringA(hrec, 1, "boo hoo");
259 ok( r == ERROR_SUCCESS, "set string failed\n");
260 sz = sizeof buffer;
261 r = MsiFormatRecordA(0, hrec, buffer, &sz);
262 ok( r == ERROR_SUCCESS, "format failed\n");
263 ok( sz == 7, "size wrong\n");
264 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
265
266 /* now put something in the first field */
267 r = MsiRecordSetStringA(hrec, 0, "[1] [2]");
268 ok( r == ERROR_SUCCESS, "set string failed\n");
269 r = MsiRecordSetStringA(hrec, 1, "boo");
270 ok( r == ERROR_SUCCESS, "set string failed\n");
271 r = MsiRecordSetStringA(hrec, 2, "hoo");
272 ok( r == ERROR_SUCCESS, "set string failed\n");
273 sz = sizeof buffer;
274 r = MsiFormatRecordA(0, hrec, buffer, &sz);
275 ok( r == ERROR_SUCCESS, "format failed\n");
276 ok( sz == 7, "size wrong\n");
277 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
278
279 /* self-referential format field */
280 r = MsiRecordSetStringA(hrec, 0, "[1] test [0]");
281 ok( r == ERROR_SUCCESS, "set string failed\n");
282 sz = sizeof buffer;
283 r = MsiFormatRecordA(0, hrec, buffer, &sz);
284 ok( r == ERROR_SUCCESS, "format failed\n");
285 ok( sz == 21, "size wrong\n");
286 ok( 0 == strcmp(buffer,"boo test [1] test [0]"), "wrong output\n");
287
288 /* empty string */
289 r = MsiRecordSetStringA(hrec, 0, "");
290 ok( r == ERROR_SUCCESS, "set string failed\n");
291 sz = sizeof buffer;
292 r = MsiFormatRecordA(0, hrec, buffer, &sz);
293 ok( r == ERROR_SUCCESS, "format failed\n");
294 ok( sz == 30, "size wrong %i\n",sz);
295 ok( 0 == strcmp(buffer,"1: boo 2: hoo 3: 4: 5: 6: "),
296 "wrong output(%s)\n",buffer);
297
298 /* empty string with numbers */
299 r = MsiRecordSetStringA(hrec, 1, "123");
300 ok( r == ERROR_SUCCESS, "set string failed\n");
301 r = MsiRecordSetInteger(hrec, 2, 4567);
302 ok( r == ERROR_SUCCESS, "set string failed\n");
303 sz = sizeof buffer;
304 r = MsiFormatRecordA(0, hrec, buffer, &sz);
305 ok( r == ERROR_SUCCESS, "format failed\n");
306 ok( sz == 31, "size wrong %i\n",sz);
307 ok( 0 == strcmp(buffer,"1: 123 2: 4567 3: 4: 5: 6: "),
308 "wrong output(%s)\n",buffer);
309
310 /* play games with recursive lookups */
311 r = MsiRecordSetStringA(hrec, 0, "[[1]] [2]");
312 ok( r == ERROR_SUCCESS, "set string failed\n");
313 r = MsiRecordSetStringA(hrec, 1, "2");
314 ok( r == ERROR_SUCCESS, "set string failed\n");
315 r = MsiRecordSetStringA(hrec, 2, "hey");
316 ok( r == ERROR_SUCCESS, "set string failed\n");
317 sz = sizeof buffer;
318 r = MsiFormatRecordA(0, hrec, buffer, &sz);
319 ok( r == ERROR_SUCCESS, "format failed\n");
320 ok( sz == 7, "size wrong,(%i)\n",sz);
321 ok( 0 == strcmp(buffer,"hey hey"), "wrong output (%s)\n",buffer);
322
323 r = MsiRecordSetStringA(hrec, 0, "[[1]] [2]");
324 ok( r == ERROR_SUCCESS, "set string failed\n");
325 r = MsiRecordSetStringA(hrec, 1, "[2]");
326 ok( r == ERROR_SUCCESS, "set string failed\n");
327 r = MsiRecordSetStringA(hrec, 2, "hey");
328 ok( r == ERROR_SUCCESS, "set string failed\n");
329 sz = sizeof buffer;
330 r = MsiFormatRecordA(0, hrec, buffer, &sz);
331 ok( r == ERROR_SUCCESS, "format failed\n");
332 ok( sz == 9, "size wrong,(%i)\n",sz);
333 ok( 0 == strcmp(buffer,"[[2]] hey"), "wrong output (%s)\n",buffer);
334
335 r = MsiRecordSetStringA(hrec, 0, "[[[3]]] [2]");
336 ok( r == ERROR_SUCCESS, "set string failed\n");
337 r = MsiRecordSetStringA(hrec, 1, "2");
338 ok( r == ERROR_SUCCESS, "set string failed\n");
339 r = MsiRecordSetStringA(hrec, 2, "hey");
340 ok( r == ERROR_SUCCESS, "set string failed\n");
341 r = MsiRecordSetStringA(hrec, 3, "1");
342 ok( r == ERROR_SUCCESS, "set string failed\n");
343 sz = sizeof buffer;
344 r = MsiFormatRecordA(0, hrec, buffer, &sz);
345 ok( r == ERROR_SUCCESS, "format failed\n");
346 ok( sz == 7, "size wrong,(%i)\n",sz);
347 ok( 0 == strcmp(buffer,"hey hey"), "wrong output (%s)\n",buffer);
348
349 r = MsiCloseHandle(hrec);
350 ok(r==ERROR_SUCCESS, "Unable to close record\n");
351 hrec = MsiCreateRecord(12);
352 ok( hrec, "failed to create record\n");
353
354 r = MsiRecordSetStringA(hrec, 0, "[[3][1]] [2]");
355 ok( r == ERROR_SUCCESS, "set string failed\n");
356 r = MsiRecordSetStringA(hrec, 1, "2");
357 ok( r == ERROR_SUCCESS, "set string failed\n");
358 r = MsiRecordSetStringA(hrec, 2, "hey");
359 ok( r == ERROR_SUCCESS, "set string failed\n");
360 r = MsiRecordSetStringA(hrec, 3, "1");
361 ok( r == ERROR_SUCCESS, "set string failed\n");
362 r = MsiRecordSetStringA(hrec, 12, "big");
363 ok( r == ERROR_SUCCESS, "set string failed\n");
364 sz = sizeof buffer;
365 r = MsiFormatRecordA(0, hrec, buffer, &sz);
366 ok( r == ERROR_SUCCESS, "format failed\n");
367 ok( sz == 7, "size wrong,(%i)\n",sz);
368 ok( 0 == strcmp(buffer,"big hey"), "wrong output (%s)\n",buffer);
369
370 r = MsiRecordSetStringA(hrec, 0, "[[3][4][1]] [2]");
371 ok( r == ERROR_SUCCESS, "set string failed\n");
372 r = MsiRecordSetStringA(hrec, 1, "2");
373 ok( r == ERROR_SUCCESS, "set string failed\n");
374 r = MsiRecordSetStringA(hrec, 2, "hey");
375 ok( r == ERROR_SUCCESS, "set string failed\n");
376 r = MsiRecordSetStringA(hrec, 3, "1");
377 ok( r == ERROR_SUCCESS, "set string failed\n");
378 r = MsiRecordSetStringA(hrec, 4, NULL);
379 ok( r == ERROR_SUCCESS, "set string failed\n");
380 r = MsiRecordSetStringA(hrec, 12, "big");
381 ok( r == ERROR_SUCCESS, "set string failed\n");
382 sz = sizeof buffer;
383 r = MsiFormatRecordA(0, hrec, buffer, &sz);
384 ok( r == ERROR_SUCCESS, "format failed\n");
385 ok( sz == 7, "size wrong,(%i)\n",sz);
386 ok( 0 == strcmp(buffer,"big hey"), "wrong output (%s)\n",buffer);
387
388 r = MsiRecordSetStringA(hrec, 0, "[[3][[4]][1]] [2]");
389 ok( r == ERROR_SUCCESS, "set string failed\n");
390 r = MsiRecordSetStringA(hrec, 1, "2");
391 ok( r == ERROR_SUCCESS, "set string failed\n");
392 r = MsiRecordSetStringA(hrec, 2, "hey");
393 ok( r == ERROR_SUCCESS, "set string failed\n");
394 r = MsiRecordSetStringA(hrec, 3, "1");
395 ok( r == ERROR_SUCCESS, "set string failed\n");
396 r = MsiRecordSetStringA(hrec, 4, NULL);
397 ok( r == ERROR_SUCCESS, "set string failed\n");
398 r = MsiRecordSetStringA(hrec, 12, "big");
399 ok( r == ERROR_SUCCESS, "set string failed\n");
400 sz = sizeof buffer;
401 r = MsiFormatRecordA(0, hrec, buffer, &sz);
402 ok( r == ERROR_SUCCESS, "format failed\n");
403 ok( sz == 10, "size wrong,(%i)\n",sz);
404 ok( 0 == strcmp(buffer,"[1[]2] hey"), "wrong output (%s)\n",buffer);
405
406 /* incorrect formats */
407 r = MsiRecordSetStringA(hrec, 0, "[[[3][[4]][1]] [2]");
408 ok( r == ERROR_SUCCESS, "set string failed\n");
409 r = MsiRecordSetStringA(hrec, 1, "2");
410 ok( r == ERROR_SUCCESS, "set string failed\n");
411 r = MsiRecordSetStringA(hrec, 2, "hey");
412 ok( r == ERROR_SUCCESS, "set string failed\n");
413 r = MsiRecordSetStringA(hrec, 3, "1");
414 ok( r == ERROR_SUCCESS, "set string failed\n");
415 r = MsiRecordSetStringA(hrec, 4, NULL);
416 ok( r == ERROR_SUCCESS, "set string failed\n");
417 r = MsiRecordSetStringA(hrec, 12, "big");
418 ok( r == ERROR_SUCCESS, "set string failed\n");
419 sz = sizeof buffer;
420 r = MsiFormatRecordA(0, hrec, buffer, &sz);
421 ok( r == ERROR_SUCCESS, "format failed\n");
422 ok( sz == 18, "size wrong,(%i)\n",sz);
423 ok( 0 == strcmp(buffer,"[[[3][[4]][1]] [2]"), "wrong output (%s)\n",buffer);
424
425 r = MsiRecordSetStringA(hrec, 0, "[[3][[4]][1]] [2]]");
426 ok( r == ERROR_SUCCESS, "set string failed\n");
427 r = MsiRecordSetStringA(hrec, 1, "2");
428 ok( r == ERROR_SUCCESS, "set string failed\n");
429 r = MsiRecordSetStringA(hrec, 2, "hey");
430 ok( r == ERROR_SUCCESS, "set string failed\n");
431 r = MsiRecordSetStringA(hrec, 3, "1");
432 ok( r == ERROR_SUCCESS, "set string failed\n");
433 r = MsiRecordSetStringA(hrec, 4, NULL);
434 ok( r == ERROR_SUCCESS, "set string failed\n");
435 r = MsiRecordSetStringA(hrec, 12, "big");
436 ok( r == ERROR_SUCCESS, "set string failed\n");
437 sz = sizeof buffer;
438 r = MsiFormatRecordA(0, hrec, buffer, &sz);
439 ok( r == ERROR_SUCCESS, "format failed\n");
440 ok( sz == 11, "size wrong,(%i)\n",sz);
441 ok( 0 == strcmp(buffer,"[1[]2] hey]"), "wrong output (%s)\n",buffer);
442
443
444 /* play games with {} */
445
446 r = MsiRecordSetStringA(hrec, 0, "{[3][1]} [2]");
447 ok( r == ERROR_SUCCESS, "set string failed\n");
448 r = MsiRecordSetStringA(hrec, 1, "2");
449 ok( r == ERROR_SUCCESS, "set string failed\n");
450 r = MsiRecordSetStringA(hrec, 2, "hey");
451 ok( r == ERROR_SUCCESS, "set string failed\n");
452 r = MsiRecordSetStringA(hrec, 3, "1");
453 ok( r == ERROR_SUCCESS, "set string failed\n");
454 r = MsiRecordSetStringA(hrec, 4, NULL);
455 ok( r == ERROR_SUCCESS, "set string failed\n");
456 r = MsiRecordSetStringA(hrec, 12, "big");
457 ok( r == ERROR_SUCCESS, "set string failed\n");
458 sz = sizeof buffer;
459 r = MsiFormatRecordA(0, hrec, buffer, &sz);
460 ok( r == ERROR_SUCCESS, "format failed\n");
461 ok( sz == 6, "size wrong,(%i)\n",sz);
462 ok( 0 == strcmp(buffer,"12 hey"), "wrong output (%s)\n",buffer);
463
464 r = MsiRecordSetStringA(hrec, 0, "[{[3][1]}] [2]");
465 ok( r == ERROR_SUCCESS, "set string failed\n");
466 r = MsiRecordSetStringA(hrec, 1, "2");
467 ok( r == ERROR_SUCCESS, "set string failed\n");
468 r = MsiRecordSetStringA(hrec, 2, "hey");
469 ok( r == ERROR_SUCCESS, "set string failed\n");
470 r = MsiRecordSetStringA(hrec, 3, "1");
471 ok( r == ERROR_SUCCESS, "set string failed\n");
472 r = MsiRecordSetStringA(hrec, 4, NULL);
473 ok( r == ERROR_SUCCESS, "set string failed\n");
474 r = MsiRecordSetStringA(hrec, 12, "big");
475 ok( r == ERROR_SUCCESS, "set string failed\n");
476 sz = sizeof buffer;
477 r = MsiFormatRecordA(0, hrec, buffer, &sz);
478 ok( r == ERROR_SUCCESS, "format failed\n");
479 ok( sz == 8, "size wrong,(%i)\n",sz);
480 ok( 0 == strcmp(buffer,"[12] hey"), "wrong output (%s)\n",buffer);
481
482
483 r = MsiRecordSetStringA(hrec, 0, "{test} [2]");
484 ok( r == ERROR_SUCCESS, "set string failed\n");
485 r = MsiRecordSetStringA(hrec, 1, "2");
486 ok( r == ERROR_SUCCESS, "set string failed\n");
487 r = MsiRecordSetStringA(hrec, 2, "hey");
488 ok( r == ERROR_SUCCESS, "set string failed\n");
489 r = MsiRecordSetStringA(hrec, 3, "1");
490 ok( r == ERROR_SUCCESS, "set string failed\n");
491 r = MsiRecordSetStringA(hrec, 4, NULL);
492 ok( r == ERROR_SUCCESS, "set string failed\n");
493 r = MsiRecordSetStringA(hrec, 12, "big");
494 ok( r == ERROR_SUCCESS, "set string failed\n");
495 sz = sizeof buffer;
496 r = MsiFormatRecordA(0, hrec, buffer, &sz);
497 ok( r == ERROR_SUCCESS, "format failed\n");
498 ok( sz == 10, "size wrong,(%i)\n",sz);
499 ok( 0 == strcmp(buffer,"{test} hey"), "wrong output (%s)\n",buffer);
500
501 r = MsiRecordSetStringA(hrec, 0, "{[test]} [2]");
502 ok( r == ERROR_SUCCESS, "set string failed\n");
503 r = MsiRecordSetStringA(hrec, 1, "2");
504 ok( r == ERROR_SUCCESS, "set string failed\n");
505 r = MsiRecordSetStringA(hrec, 2, "hey");
506 ok( r == ERROR_SUCCESS, "set string failed\n");
507 r = MsiRecordSetStringA(hrec, 3, "1");
508 ok( r == ERROR_SUCCESS, "set string failed\n");
509 r = MsiRecordSetStringA(hrec, 4, NULL);
510 ok( r == ERROR_SUCCESS, "set string failed\n");
511 r = MsiRecordSetStringA(hrec, 12, "big");
512 ok( r == ERROR_SUCCESS, "set string failed\n");
513 sz = sizeof buffer;
514 r = MsiFormatRecordA(0, hrec, buffer, &sz);
515 ok( r == ERROR_SUCCESS, "format failed\n");
516 ok( sz == 12, "size wrong,(%i)\n",sz);
517 ok( 0 == strcmp(buffer,"{[test]} hey"), "wrong output (%s)\n",buffer);
518
519 r = MsiRecordSetStringA(hrec, 0, "{[1][2][3][4]} [2]");
520 ok( r == ERROR_SUCCESS, "set string failed\n");
521 r = MsiRecordSetStringA(hrec, 1, "2");
522 ok( r == ERROR_SUCCESS, "set string failed\n");
523 r = MsiRecordSetStringA(hrec, 2, "hey");
524 ok( r == ERROR_SUCCESS, "set string failed\n");
525 r = MsiRecordSetStringA(hrec, 3, "1");
526 ok( r == ERROR_SUCCESS, "set string failed\n");
527 r = MsiRecordSetStringA(hrec, 4, NULL);
528 ok( r == ERROR_SUCCESS, "set string failed\n");
529 r = MsiRecordSetStringA(hrec, 12, "big");
530 ok( r == ERROR_SUCCESS, "set string failed\n");
531 sz = sizeof buffer;
532 r = MsiFormatRecordA(0, hrec, buffer, &sz);
533 ok( r == ERROR_SUCCESS, "format failed\n");
534 ok( sz == 4, "size wrong,(%i)\n",sz);
535 ok( 0 == strcmp(buffer," hey"), "wrong output (%s)\n",buffer);
536
537 r = MsiRecordSetStringA(hrec, 0, "{[1][2][3][dummy]} [2]");
538 ok( r == ERROR_SUCCESS, "set string failed\n");
539 r = MsiRecordSetStringA(hrec, 1, "2");
540 ok( r == ERROR_SUCCESS, "set string failed\n");
541 r = MsiRecordSetStringA(hrec, 2, "hey");
542 ok( r == ERROR_SUCCESS, "set string failed\n");
543 r = MsiRecordSetStringA(hrec, 3, "1");
544 ok( r == ERROR_SUCCESS, "set string failed\n");
545 r = MsiRecordSetStringA(hrec, 4, NULL);
546 ok( r == ERROR_SUCCESS, "set string failed\n");
547 r = MsiRecordSetStringA(hrec, 12, "big");
548 ok( r == ERROR_SUCCESS, "set string failed\n");
549 sz = sizeof buffer;
550 r = MsiFormatRecordA(0, hrec, buffer, &sz);
551 ok( r == ERROR_SUCCESS, "format failed\n");
552 ok( sz == 18, "size wrong,(%i)\n",sz);
553 ok( 0 == strcmp(buffer,"{2hey1[dummy]} hey"), "wrong output (%s)\n",buffer);
554
555 r = MsiRecordSetStringA(hrec, 0, "{[1][2][3][4][dummy]} [2]");
556 ok( r == ERROR_SUCCESS, "set string failed\n");
557 r = MsiRecordSetStringA(hrec, 1, "2");
558 ok( r == ERROR_SUCCESS, "set string failed\n");
559 r = MsiRecordSetStringA(hrec, 2, "hey");
560 ok( r == ERROR_SUCCESS, "set string failed\n");
561 r = MsiRecordSetStringA(hrec, 3, "1");
562 ok( r == ERROR_SUCCESS, "set string failed\n");
563 r = MsiRecordSetStringA(hrec, 4, NULL);
564 ok( r == ERROR_SUCCESS, "set string failed\n");
565 r = MsiRecordSetStringA(hrec, 12, "big");
566 ok( r == ERROR_SUCCESS, "set string failed\n");
567 sz = sizeof buffer;
568 r = MsiFormatRecordA(0, hrec, buffer, &sz);
569 ok( r == ERROR_SUCCESS, "format failed\n");
570 ok( sz == 18, "size wrong,(%i)\n",sz);
571 ok( 0 == strcmp(buffer,"{2hey1[dummy]} hey"), "wrong output (%s)\n",buffer);
572
573 r = MsiRecordSetStringA(hrec, 0, "{{[1][2]}[3][4][dummy]}");
574 ok( r == ERROR_SUCCESS, "set string failed\n");
575 r = MsiRecordSetStringA(hrec, 1, "2");
576 ok( r == ERROR_SUCCESS, "set string failed\n");
577 r = MsiRecordSetStringA(hrec, 2, "hey");
578 ok( r == ERROR_SUCCESS, "set string failed\n");
579 r = MsiRecordSetStringA(hrec, 3, "1");
580 ok( r == ERROR_SUCCESS, "set string failed\n");
581 r = MsiRecordSetStringA(hrec, 4, NULL);
582 ok( r == ERROR_SUCCESS, "set string failed\n");
583 r = MsiRecordSetStringA(hrec, 12, "big");
584 ok( r == ERROR_SUCCESS, "set string failed\n");
585 sz = sizeof buffer;
586 r = MsiFormatRecordA(0, hrec, buffer, &sz);
587 ok( r == ERROR_SUCCESS, "format failed\n");
588 ok( sz == 16, "size wrong,(%i)\n",sz);
589 ok( 0 == strcmp(buffer,"{{2hey}1[dummy]}"), "wrong output (%s)\n",buffer);
590
591 r = MsiRecordSetStringA(hrec, 0, "{{[1][2]}[3]{[4][dummy]}}");
592 ok( r == ERROR_SUCCESS, "set string failed\n");
593 r = MsiRecordSetStringA(hrec, 1, "2");
594 ok( r == ERROR_SUCCESS, "set string failed\n");
595 r = MsiRecordSetStringA(hrec, 2, "hey");
596 ok( r == ERROR_SUCCESS, "set string failed\n");
597 r = MsiRecordSetStringA(hrec, 3, "1");
598 ok( r == ERROR_SUCCESS, "set string failed\n");
599 r = MsiRecordSetStringA(hrec, 4, NULL);
600 ok( r == ERROR_SUCCESS, "set string failed\n");
601 r = MsiRecordSetStringA(hrec, 12, "big");
602 ok( r == ERROR_SUCCESS, "set string failed\n");
603 sz = sizeof buffer;
604 r = MsiFormatRecordA(0, hrec, buffer, &sz);
605 ok( r == ERROR_SUCCESS, "format failed\n");
606 ok( sz == 0, "size wrong,(%i)\n",sz);
607 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
608
609 r = MsiRecordSetStringA(hrec, 0, "{{[1][2]}[3]} {[1][2]}");
610 ok( r == ERROR_SUCCESS, "set string failed\n");
611 r = MsiRecordSetStringA(hrec, 1, "1");
612 ok( r == ERROR_SUCCESS, "set string failed\n");
613 r = MsiRecordSetStringA(hrec, 2, "2");
614 ok( r == ERROR_SUCCESS, "set string failed\n");
615 r = MsiRecordSetStringA(hrec, 3, "3");
616 ok( r == ERROR_SUCCESS, "set string failed\n");
617 r = MsiRecordSetStringA(hrec, 4, NULL);
618 ok( r == ERROR_SUCCESS, "set string failed\n");
619 r = MsiRecordSetStringA(hrec, 12, "big");
620 ok( r == ERROR_SUCCESS, "set string failed\n");
621 sz = sizeof buffer;
622 r = MsiFormatRecordA(0, hrec, buffer, &sz);
623 ok( r == ERROR_SUCCESS, "format failed\n");
624 ok( sz == 12, "size wrong,(%i)\n",sz);
625 ok( 0 == strcmp(buffer,"{{12}3} {12}"), "wrong output (%s)\n",buffer);
626
627 r = MsiRecordSetStringA(hrec, 0, "{[1][2]} {{[1][2]}[3]} {[1][2]}");
628 ok( r == ERROR_SUCCESS, "set string failed\n");
629 r = MsiRecordSetStringA(hrec, 1, "1");
630 ok( r == ERROR_SUCCESS, "set string failed\n");
631 r = MsiRecordSetStringA(hrec, 2, "2");
632 ok( r == ERROR_SUCCESS, "set string failed\n");
633 r = MsiRecordSetStringA(hrec, 3, "3");
634 ok( r == ERROR_SUCCESS, "set string failed\n");
635 r = MsiRecordSetStringA(hrec, 4, NULL);
636 ok( r == ERROR_SUCCESS, "set string failed\n");
637 r = MsiRecordSetStringA(hrec, 12, "big");
638 ok( r == ERROR_SUCCESS, "set string failed\n");
639 sz = sizeof buffer;
640 r = MsiFormatRecordA(0, hrec, buffer, &sz);
641 ok( r == ERROR_SUCCESS, "format failed\n");
642 ok( sz == 15, "size wrong,(%i)\n",sz);
643 ok( 0 == strcmp(buffer,"12 {{12}3} {12}"), "wrong output (%s)\n",buffer);
644
645 r = MsiRecordSetStringA(hrec, 0, "{[4]}{[1][2]} {{[1][2]}[3]} {[1][2]}");
646 ok( r == ERROR_SUCCESS, "set string failed\n");
647 r = MsiRecordSetStringA(hrec, 1, "1");
648 ok( r == ERROR_SUCCESS, "set string failed\n");
649 r = MsiRecordSetStringA(hrec, 2, "2");
650 ok( r == ERROR_SUCCESS, "set string failed\n");
651 r = MsiRecordSetStringA(hrec, 3, "3");
652 ok( r == ERROR_SUCCESS, "set string failed\n");
653 r = MsiRecordSetStringA(hrec, 4, NULL);
654 ok( r == ERROR_SUCCESS, "set string failed\n");
655 r = MsiRecordSetStringA(hrec, 12, "big");
656 ok( r == ERROR_SUCCESS, "set string failed\n");
657 sz = sizeof buffer;
658 r = MsiFormatRecordA(0, hrec, buffer, &sz);
659 ok( r == ERROR_SUCCESS, "format failed\n");
660 ok( sz == 15, "size wrong,(%i)\n",sz);
661 ok( 0 == strcmp(buffer,"12 {{12}3} {12}"), "wrong output (%s)\n",buffer);
662
663 r = MsiRecordSetStringA(hrec, 0, "{blah} {[4]}{[1][2]} {{[1][2]}[3]} {[1][2]}");
664 ok( r == ERROR_SUCCESS, "set string failed\n");
665 r = MsiRecordSetStringA(hrec, 1, "1");
666 ok( r == ERROR_SUCCESS, "set string failed\n");
667 r = MsiRecordSetStringA(hrec, 2, "2");
668 ok( r == ERROR_SUCCESS, "set string failed\n");
669 r = MsiRecordSetStringA(hrec, 3, "3");
670 ok( r == ERROR_SUCCESS, "set string failed\n");
671 r = MsiRecordSetStringA(hrec, 4, NULL);
672 ok( r == ERROR_SUCCESS, "set string failed\n");
673 r = MsiRecordSetStringA(hrec, 12, "big");
674 ok( r == ERROR_SUCCESS, "set string failed\n");
675 sz = sizeof buffer;
676 r = MsiFormatRecordA(0, hrec, buffer, &sz);
677 ok( r == ERROR_SUCCESS, "format failed\n");
678 ok( sz == 22, "size wrong,(%i)\n",sz);
679 ok( 0 == strcmp(buffer,"{blah} 12 {{12}3} {12}"), "wrong output (%s)\n",buffer);
680
681 r = MsiRecordSetStringA(hrec, 0, "{{[1]}[2]} {[4]}{[1][2]}");
682 ok( r == ERROR_SUCCESS, "set string failed\n");
683 r = MsiRecordSetStringA(hrec, 1, "1");
684 ok( r == ERROR_SUCCESS, "set string failed\n");
685 r = MsiRecordSetStringA(hrec, 2, "2");
686 ok( r == ERROR_SUCCESS, "set string failed\n");
687 r = MsiRecordSetStringA(hrec, 3, "3");
688 ok( r == ERROR_SUCCESS, "set string failed\n");
689 r = MsiRecordSetStringA(hrec, 4, NULL);
690 ok( r == ERROR_SUCCESS, "set string failed\n");
691 r = MsiRecordSetStringA(hrec, 12, "big");
692 ok( r == ERROR_SUCCESS, "set string failed\n");
693 sz = sizeof buffer;
694 r = MsiFormatRecordA(0, hrec, buffer, &sz);
695 ok( r == ERROR_SUCCESS, "format failed\n");
696 ok( sz == 13, "size wrong,(%i)\n",sz);
697 ok( 0 == strcmp(buffer,"{{1}2} {}{12}"), "wrong output (%s)\n",buffer);
698
699 r = MsiRecordSetStringA(hrec, 0, "{{[1]}} {[4]}{[1][2]}");
700 ok( r == ERROR_SUCCESS, "set string failed\n");
701 r = MsiRecordSetStringA(hrec, 1, "1");
702 ok( r == ERROR_SUCCESS, "set string failed\n");
703 r = MsiRecordSetStringA(hrec, 2, "2");
704 ok( r == ERROR_SUCCESS, "set string failed\n");
705 r = MsiRecordSetStringA(hrec, 3, "3");
706 ok( r == ERROR_SUCCESS, "set string failed\n");
707 r = MsiRecordSetStringA(hrec, 4, NULL);
708 ok( r == ERROR_SUCCESS, "set string failed\n");
709 r = MsiRecordSetStringA(hrec, 12, "big");
710 ok( r == ERROR_SUCCESS, "set string failed\n");
711 sz = sizeof buffer;
712 r = MsiFormatRecordA(0, hrec, buffer, &sz);
713 ok( r == ERROR_SUCCESS, "format failed\n");
714 ok( sz == 3, "size wrong,(%i)\n",sz);
715 ok( 0 == strcmp(buffer," 12"), "wrong output (%s)\n",buffer);
716
717 r = MsiRecordSetStringA(hrec, 0, "{{{[1]}} {[4]}{[1][2]}");
718 ok( r == ERROR_SUCCESS, "set string failed\n");
719 r = MsiRecordSetStringA(hrec, 1, "1");
720 ok( r == ERROR_SUCCESS, "set string failed\n");
721 r = MsiRecordSetStringA(hrec, 2, "2");
722 ok( r == ERROR_SUCCESS, "set string failed\n");
723 r = MsiRecordSetStringA(hrec, 3, "3");
724 ok( r == ERROR_SUCCESS, "set string failed\n");
725 r = MsiRecordSetStringA(hrec, 4, NULL);
726 ok( r == ERROR_SUCCESS, "set string failed\n");
727 r = MsiRecordSetStringA(hrec, 12, "big");
728 ok( r == ERROR_SUCCESS, "set string failed\n");
729 sz = sizeof buffer;
730 r = MsiFormatRecordA(0, hrec, buffer, &sz);
731 ok( r == ERROR_SUCCESS, "format failed\n");
732 todo_wine{
733 ok( sz == 3, "size wrong,(%i)\n",sz);
734 ok( 0 == strcmp(buffer," 12"), "wrong output (%s)\n",buffer);
735 }
736
737 /* now put play games with escaping */
738 r = MsiRecordSetStringA(hrec, 0, "[1] [2] [\\3asdf]");
739 ok( r == ERROR_SUCCESS, "set string failed\n");
740 r = MsiRecordSetStringA(hrec, 1, "boo");
741 ok( r == ERROR_SUCCESS, "set string failed\n");
742 r = MsiRecordSetStringA(hrec, 2, "hoo");
743 ok( r == ERROR_SUCCESS, "set string failed\n");
744 sz = sizeof buffer;
745 r = MsiFormatRecordA(0, hrec, buffer, &sz);
746 ok( r == ERROR_SUCCESS, "format failed\n");
747 ok( sz == 16, "size wrong\n");
748 ok( 0 == strcmp(buffer,"boo hoo [\\3asdf]"), "wrong output\n");
749
750 /* now put play games with escaping */
751 r = MsiRecordSetStringA(hrec, 0, "[1] [2] [\\x]");
752 ok( r == ERROR_SUCCESS, "set string failed\n");
753 r = MsiRecordSetStringA(hrec, 1, "boo");
754 ok( r == ERROR_SUCCESS, "set string failed\n");
755 r = MsiRecordSetStringA(hrec, 2, "hoo");
756 ok( r == ERROR_SUCCESS, "set string failed\n");
757 sz = sizeof buffer;
758 r = MsiFormatRecordA(0, hrec, buffer, &sz);
759 ok( r == ERROR_SUCCESS, "format failed\n");
760 ok( sz == 12, "size wrong\n");
761 ok( 0 == strcmp(buffer,"boo hoo [\\x]"), "wrong output\n");
762
763 r = MsiRecordSetStringA(hrec, 0, "[\\x]");
764 ok( r == ERROR_SUCCESS, "set string failed\n");
765 sz = sizeof buffer;
766 r = MsiFormatRecordA(0, hrec, buffer, &sz);
767 ok( r == ERROR_SUCCESS, "format failed\n");
768 ok( sz == 4, "size wrong: %d\n", sz);
769 ok( 0 == strcmp(buffer,"[\\x]"), "wrong output: %s\n", buffer);
770
771 r = MsiRecordSetStringA(hrec, 0, "{\\x}");
772 ok( r == ERROR_SUCCESS, "set string failed\n");
773 sz = sizeof buffer;
774 r = MsiFormatRecordA(0, hrec, buffer, &sz);
775 ok( r == ERROR_SUCCESS, "format failed\n");
776 ok( sz == 4, "size wrong: %d\n", sz);
777 ok( 0 == strcmp(buffer,"{\\x}"), "wrong output: %s\n", buffer);
778
779 r = MsiRecordSetStringA(hrec, 0, "[abc\\x]");
780 ok( r == ERROR_SUCCESS, "set string failed\n");
781 sz = sizeof buffer;
782 r = MsiFormatRecordA(0, hrec, buffer, &sz);
783 ok( r == ERROR_SUCCESS, "format failed\n");
784 ok( sz == 7, "size wrong: %d\n", sz);
785 ok( 0 == strcmp(buffer,"[abc\\x]"), "wrong output: %s\n", buffer);
786
787 r = MsiRecordSetStringA(hrec, 0, "[\\[]Bracket Text[\\]]");
788 ok( r == ERROR_SUCCESS, "set string failed\n");
789 sz = sizeof buffer;
790 r = MsiFormatRecordA(0, hrec, buffer, &sz);
791 ok( r == ERROR_SUCCESS, "format failed\n");
792 ok( sz == 20, "size wrong: %d\n", sz);
793 ok( 0 == strcmp(buffer,"[\\[]Bracket Text[\\]]"), "wrong output: %s\n", buffer);
794
795 /* now try other formats without a package */
796 r = MsiRecordSetStringA(hrec, 0, "[1] [2] [property]");
797 ok( r == ERROR_SUCCESS, "set string failed\n");
798 r = MsiRecordSetStringA(hrec, 1, "boo");
799 ok( r == ERROR_SUCCESS, "set string failed\n");
800 r = MsiRecordSetStringA(hrec, 2, "hoo");
801 ok( r == ERROR_SUCCESS, "set string failed\n");
802 sz = sizeof buffer;
803 r = MsiFormatRecordA(0, hrec, buffer, &sz);
804 ok( r == ERROR_SUCCESS, "format failed\n");
805 ok( sz == 18, "size wrong\n");
806 ok( 0 == strcmp(buffer,"boo hoo [property]"), "wrong output\n");
807
808 r = MsiRecordSetStringA(hrec, 0, "[1] [~] [2]");
809 ok( r == ERROR_SUCCESS, "set string failed\n");
810 r = MsiRecordSetStringA(hrec, 1, "boo");
811 ok( r == ERROR_SUCCESS, "set string failed\n");
812 r = MsiRecordSetStringA(hrec, 2, "hoo");
813 ok( r == ERROR_SUCCESS, "set string failed\n");
814 sz = sizeof buffer;
815 r = MsiFormatRecordA(0, hrec, buffer, &sz);
816 ok( r == ERROR_SUCCESS, "format failed\n");
817 ok( sz == 11, "size wrong\n");
818 ok( 0 == strcmp(buffer,"boo [~] hoo"), "wrong output (%s)\n",buffer);
819
820 r = MsiRecordSetStringA(hrec, 0, "[1]");
821 ok( r == ERROR_SUCCESS, "set string failed\n");
822 r = MsiRecordSetInteger(hrec, 1, 123456);
823 ok( r == ERROR_SUCCESS, "set integer failed\n");
824 sz = sizeof buffer;
825 r = MsiFormatRecordA(0, hrec, buffer, &sz);
826 ok( r == ERROR_SUCCESS, "format failed\n");
827 ok( sz == 6, "size wrong\n");
828 ok( 0 == strcmp(buffer,"123456"), "wrong output (%s)\n",buffer);
829
830 r = MsiRecordSetStringA(hrec, 0, "[~]");
831 ok( r == ERROR_SUCCESS, "set string failed\n");
832 sz = sizeof buffer;
833 r = MsiFormatRecordA(0, hrec, buffer, &sz);
834 ok( sz == 3, "size wrong\n");
835 ok( 0 == strcmp(buffer,"[~]"), "wrong output\n");
836 ok( r == ERROR_SUCCESS, "format failed\n");
837
838 r = MsiRecordSetStringA(hrec, 0, "[]");
839 ok( r == ERROR_SUCCESS, "set string failed\n");
840 sz = sizeof buffer;
841 r = MsiFormatRecordA(0, hrec, buffer, &sz);
842 ok( sz == 2, "size wrong\n");
843 ok( 0 == strcmp(buffer,"[]"), "wrong output\n");
844 ok( r == ERROR_SUCCESS, "format failed\n");
845
846 /* MsiFormatRecordA doesn't seem to handle a negative too well */
847 r = MsiRecordSetStringA(hrec, 0, "[-1]");
848 ok( r == ERROR_SUCCESS, "set string failed\n");
849 sz = sizeof buffer;
850 r = MsiFormatRecordA(0, hrec, buffer, &sz);
851 ok( sz == 4, "size wrong\n");
852 ok( 0 == strcmp(buffer,"[-1]"), "wrong output\n");
853 ok( r == ERROR_SUCCESS, "format failed\n");
854
855 r = MsiRecordSetStringA(hrec, 0, "{[]}");
856 ok( r == ERROR_SUCCESS, "set string failed\n");
857 sz = sizeof buffer;
858 r = MsiFormatRecordA(0, hrec, buffer, &sz);
859 ok( sz == 4, "size wrong\n");
860 ok( 0 == strcmp(buffer,"{[]}"), "wrong output\n");
861 ok( r == ERROR_SUCCESS, "format failed\n");
862
863 r = MsiRecordSetStringA(hrec, 0, "[0]");
864 ok( r == ERROR_SUCCESS, "set string failed\n");
865 sz = sizeof buffer;
866 r = MsiFormatRecordA(0, hrec, buffer, &sz);
867 ok( sz == 3, "size wrong\n");
868 ok( 0 == strcmp(buffer,"[0]"), "wrong output\n");
869 ok( r == ERROR_SUCCESS, "format failed\n");
870
871 r = MsiRecordSetStringA(hrec, 0, "[100]");
872 ok( r == ERROR_SUCCESS, "set string failed\n");
873 sz = sizeof buffer;
874 r = MsiFormatRecordA(0, hrec, buffer, &sz);
875 ok( sz == 0, "size wrong\n");
876 ok( 0 == strcmp(buffer,""), "wrong output\n");
877 ok( r == ERROR_SUCCESS, "format failed\n");
878
879 r = MsiRecordSetStringA(hrec, 0, "{[1] [2]}");
880 ok( r == ERROR_SUCCESS, "set string failed\n");
881 r = MsiRecordSetStringA(hrec, 1, "boo");
882 ok( r == ERROR_SUCCESS, "set string failed\n");
883 r = MsiRecordSetStringA(hrec, 2, "hoo");
884 ok( r == ERROR_SUCCESS, "set string failed\n");
885 sz = sizeof buffer;
886 r = MsiFormatRecordA(0, hrec, buffer, &sz);
887 ok( sz == 7, "size wrong\n");
888 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
889 ok( r == ERROR_SUCCESS, "format failed\n");
890
891 r = MsiRecordSetStringA(hrec, 0, "{}");
892 ok( r == ERROR_SUCCESS, "set string failed\n");
893 sz = sizeof buffer;
894 r = MsiFormatRecordA(0, hrec, buffer, &sz);
895 ok( sz == 0, "size wrong\n");
896 ok( 0 == strcmp(buffer,""), "wrong output\n");
897 ok( r == ERROR_SUCCESS, "format failed\n");
898
899 r = MsiRecordSetStringA(hrec, 0, "{foo}");
900 ok( r == ERROR_SUCCESS, "set string failed\n");
901 sz = sizeof buffer;
902 r = MsiFormatRecordA(0, hrec, buffer, &sz);
903 ok( sz == 5, "size wrong\n");
904 ok( 0 == strcmp(buffer,"{foo}"), "wrong output\n");
905 ok( r == ERROR_SUCCESS, "format failed\n");
906
907 r = MsiRecordSetStringA(hrec, 0, "{boo [1]}");
908 ok( r == ERROR_SUCCESS, "set string failed\n");
909 r = MsiRecordSetStringA(hrec, 1, "hoo");
910 ok( r == ERROR_SUCCESS, "set string failed\n");
911 sz = sizeof buffer;
912 r = MsiFormatRecordA(0, hrec, buffer, &sz);
913 ok( sz == 7, "size wrong\n");
914 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
915 ok( r == ERROR_SUCCESS, "format failed\n");
916
917 r = MsiRecordSetStringA(hrec, 0, "{{[1]}}");
918 ok( r == ERROR_SUCCESS, "set string failed\n");
919 r = MsiRecordSetStringA(hrec, 1, "hoo");
920 ok( r == ERROR_SUCCESS, "set string failed\n");
921 sz = sizeof buffer;
922 r = MsiFormatRecordA(0, hrec, buffer, &sz);
923 ok( sz == 0, "size wrong\n");
924 ok( 0 == strcmp(buffer,""), "wrong output\n");
925 ok( r == ERROR_SUCCESS, "format failed\n");
926
927 r = MsiRecordSetStringA(hrec, 0, "{ {[1]}}");
928 ok( r == ERROR_SUCCESS, "set string failed\n");
929 r = MsiRecordSetStringA(hrec, 1, "hoo");
930 ok( r == ERROR_SUCCESS, "set string failed\n");
931 sz = sizeof buffer;
932 r = MsiFormatRecordA(0, hrec, buffer, &sz);
933 todo_wine
934 {
935 ok( 0 == strcmp(buffer," {hoo}"), "wrong output\n");
936 ok( sz == 6, "size wrong\n");
937 }
938 ok( r == ERROR_SUCCESS, "format failed\n");
939
940 r = MsiRecordSetStringA(hrec, 0, "{{[1]} }");
941 ok( r == ERROR_SUCCESS, "set string failed\n");
942 r = MsiRecordSetStringA(hrec, 1, "hoo");
943 ok( r == ERROR_SUCCESS, "set string failed\n");
944 sz = sizeof buffer;
945 r = MsiFormatRecordA(0, hrec, buffer, &sz);
946 ok( sz == 8, "size wrong\n");
947 ok( 0 == strcmp(buffer,"{{hoo} }"), "wrong output\n");
948 ok( r == ERROR_SUCCESS, "format failed\n");
949
950 r = MsiRecordSetStringA(hrec, 0, "{{ [1]}}");
951 ok( r == ERROR_SUCCESS, "set string failed\n");
952 r = MsiRecordSetStringA(hrec, 1, "hoo");
953 ok( r == ERROR_SUCCESS, "set string failed\n");
954 sz = sizeof buffer;
955 r = MsiFormatRecordA(0, hrec, buffer, &sz);
956 ok( sz == 0, "size wrong\n");
957 ok( 0 == strcmp(buffer,""), "wrong output\n");
958 ok( r == ERROR_SUCCESS, "format failed\n");
959
960 r = MsiRecordSetStringA(hrec, 0, "{{[1] }}");
961 ok( r == ERROR_SUCCESS, "set string failed\n");
962 r = MsiRecordSetStringA(hrec, 1, "hoo");
963 ok( r == ERROR_SUCCESS, "set string failed\n");
964 sz = sizeof buffer;
965 r = MsiFormatRecordA(0, hrec, buffer, &sz);
966 ok( sz == 0, "size wrong\n");
967 ok( 0 == strcmp(buffer,""), "wrong output\n");
968 ok( r == ERROR_SUCCESS, "format failed\n");
969
970 r = MsiRecordSetStringA(hrec, 0, "{{a}{b}{c }{ d}{any text}}");
971 ok( r == ERROR_SUCCESS, "set string failed\n");
972 sz = sizeof buffer;
973 r = MsiFormatRecordA(0, hrec, buffer, &sz);
974 ok( sz == 0, "size wrong\n");
975 ok( 0 == strcmp(buffer,""), "wrong output\n");
976 ok( r == ERROR_SUCCESS, "format failed\n");
977
978 r = MsiRecordSetStringA(hrec, 0, "{{a} }");
979 ok( r == ERROR_SUCCESS, "set string failed\n");
980 sz = sizeof buffer;
981 r = MsiFormatRecordA(0, hrec, buffer, &sz);
982 ok( sz == 6, "size wrong\n");
983 ok( 0 == strcmp(buffer,"{{a} }"), "wrong output\n");
984 ok( r == ERROR_SUCCESS, "format failed\n");
985
986 r = MsiRecordSetStringA(hrec, 0, "{{a} {b}}");
987 ok( r == ERROR_SUCCESS, "set string failed\n");
988 sz = sizeof buffer;
989 r = MsiFormatRecordA(0, hrec, buffer, &sz);
990 ok( sz == 0, "size wrong\n");
991 ok( 0 == strcmp(buffer,""), "wrong output\n");
992 ok( r == ERROR_SUCCESS, "format failed\n");
993
994 r = MsiRecordSetStringA(hrec, 0, "{{a} b}}");
995 ok( r == ERROR_SUCCESS, "set string failed\n");
996 sz = sizeof buffer;
997 r = MsiFormatRecordA(0, hrec, buffer, &sz);
998 todo_wine ok( sz == 0, "size wrong\n");
999 todo_wine ok( 0 == strcmp(buffer,""), "wrong output\n");
1000 ok( r == ERROR_SUCCESS, "format failed\n");
1001
1002 r = MsiRecordSetStringA(hrec, 0, "{{a b}}");
1003 ok( r == ERROR_SUCCESS, "set string failed\n");
1004 sz = sizeof buffer;
1005 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1006 ok( sz == 0, "size wrong\n");
1007 ok( 0 == strcmp(buffer,""), "wrong output\n");
1008 ok( r == ERROR_SUCCESS, "format failed\n");
1009
1010 r = MsiRecordSetStringA(hrec, 0, "{ }");
1011 ok( r == ERROR_SUCCESS, "set string failed\n");
1012 sz = sizeof buffer;
1013 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1014 ok( sz == 3, "size wrong\n");
1015 ok( 0 == strcmp(buffer,"{ }"), "wrong output\n");
1016 ok( r == ERROR_SUCCESS, "format failed\n");
1017
1018 r = MsiRecordSetStringA(hrec, 0, " {{a}}}");
1019 ok( r == ERROR_SUCCESS, "set string failed\n");
1020 sz = sizeof buffer;
1021 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1022 ok( sz == 2, "size wrong\n");
1023 ok( 0 == strcmp(buffer," }"), "wrong output\n");
1024 ok( r == ERROR_SUCCESS, "format failed\n");
1025
1026 r = MsiRecordSetStringA(hrec, 0, "{{ almost {{ any }} text }}");
1027 ok( r == ERROR_SUCCESS, "set string failed\n");
1028 sz = sizeof buffer;
1029 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1030 todo_wine ok( sz == 8, "size wrong\n");
1031 todo_wine ok( 0 == strcmp(buffer," text }}"), "wrong output\n");
1032 ok( r == ERROR_SUCCESS, "format failed\n");
1033
1034 r = MsiRecordSetStringA(hrec, 0, "{{ } { hidden ][ [ }}");
1035 ok( r == ERROR_SUCCESS, "set string failed\n");
1036 sz = sizeof buffer;
1037 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1038 todo_wine ok( sz == 0, "size wrong\n");
1039 todo_wine ok( 0 == strcmp(buffer,""), "wrong output\n");
1040 ok( r == ERROR_SUCCESS, "format failed\n");
1041
1042 r = MsiRecordSetStringA(hrec, 0, "[ 1]");
1043 ok( r == ERROR_SUCCESS, "set string failed\n");
1044 r = MsiRecordSetStringA(hrec, 1, "hoo");
1045 ok( r == ERROR_SUCCESS, "set string failed\n");
1046 sz = sizeof buffer;
1047 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1048 ok( sz == 4, "size wrong\n");
1049 ok( 0 == strcmp(buffer,"[ 1]"), "wrong output\n");
1050 ok( r == ERROR_SUCCESS, "format failed\n");
1051
1052 r = MsiRecordSetStringA(hrec, 0, "[01]");
1053 ok( r == ERROR_SUCCESS, "set string failed\n");
1054 r = MsiRecordSetStringA(hrec, 1, "hoo");
1055 ok( r == ERROR_SUCCESS, "set string failed\n");
1056 sz = sizeof buffer;
1057 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1058 ok( sz == 3, "size wrong\n");
1059 ok( 0 == strcmp(buffer,"hoo"), "wrong output\n");
1060 ok( r == ERROR_SUCCESS, "format failed\n");
1061
1062 r = MsiRecordSetStringA(hrec, 0, "{{test}} [01");
1063 ok( r == ERROR_SUCCESS, "set string failed\n");
1064 r = MsiRecordSetStringA(hrec, 1, "hoo");
1065 ok( r == ERROR_SUCCESS, "set string failed\n");
1066 sz = sizeof buffer;
1067 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1068 todo_wine ok( sz == 4, "size wrong\n");
1069 todo_wine ok( 0 == strcmp(buffer," [01"), "wrong output\n");
1070 ok( r == ERROR_SUCCESS, "format failed\n");
1071
1072 r = MsiRecordSetStringA(hrec, 0, "[\\[]");
1073 ok( r == ERROR_SUCCESS, "set string failed\n");
1074 r = MsiRecordSetStringA(hrec, 1, "hoo");
1075 ok( r == ERROR_SUCCESS, "set string failed\n");
1076 sz = sizeof buffer;
1077 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1078 ok( sz == 4, "size wrong\n");
1079 ok( 0 == strcmp(buffer,"[\\[]"), "wrong output\n");
1080 ok( r == ERROR_SUCCESS, "format failed\n");
1081
1082 r = MsiRecordSetStringA(hrec, 0, "[\\[]");
1083 ok( r == ERROR_SUCCESS, "set string failed\n");
1084 r = MsiRecordSetStringA(hrec, 1, "hoo");
1085 ok( r == ERROR_SUCCESS, "set string failed\n");
1086 sz = sizeof(buffer);
1087 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1088 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1089 ok(sz == 4, "Expected 4, got %d\n", sz);
1090 ok(!lstrcmpA(buffer, "[\\[]"), "Expected \"[\\[]\", got \"%s\"\n", buffer);
1091
1092 r = MsiRecordSetStringA(hrec, 0, "[foo]");
1093 ok( r == ERROR_SUCCESS, "set string failed\n");
1094 r = MsiRecordSetStringA(hrec, 1, "hoo");
1095 ok( r == ERROR_SUCCESS, "set string failed\n");
1096 sz = sizeof buffer;
1097 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1098 ok( sz == 5, "size wrong\n");
1099 ok( 0 == strcmp(buffer,"[foo]"), "wrong output\n");
1100 ok( r == ERROR_SUCCESS, "format failed\n");
1101
1102 r = MsiRecordSetStringA(hrec, 0, "[01.]");
1103 ok( r == ERROR_SUCCESS, "set string failed\n");
1104 r = MsiRecordSetStringA(hrec, 1, "hoo");
1105 ok( r == ERROR_SUCCESS, "set string failed\n");
1106 sz = sizeof buffer;
1107 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1108 ok( sz == 5, "size wrong\n");
1109 ok( 0 == strcmp(buffer,"[01.]"), "wrong output\n");
1110 ok( r == ERROR_SUCCESS, "format failed\n");
1111
1112 SetEnvironmentVariableA("FOO", "BAR");
1113 r = MsiRecordSetStringA(hrec, 0, "[%FOO]");
1114 ok( r == ERROR_SUCCESS, "set string failed\n");
1115 sz = sizeof buffer;
1116 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1117 ok( sz == 6, "size wrong\n");
1118 ok( 0 == strcmp(buffer,"[%FOO]"), "wrong output\n");
1119 ok( r == ERROR_SUCCESS, "format failed\n");
1120
1121 r = MsiRecordSetStringA(hrec, 0, "{{[1]}");
1122 ok( r == ERROR_SUCCESS, "set string failed\n");
1123 r = MsiRecordSetStringA(hrec, 1, "hoo");
1124 ok( r == ERROR_SUCCESS, "set string failed\n");
1125 sz = sizeof buffer;
1126 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1127 ok( sz == 6, "size wrong\n");
1128 ok( 0 == strcmp(buffer,"{{hoo}"), "wrong output\n");
1129 ok( r == ERROR_SUCCESS, "format failed\n");
1130
1131 r = MsiRecordSetStringA(hrec, 0, "{{ {[1]}");
1132 ok( r == ERROR_SUCCESS, "set string failed\n");
1133 r = MsiRecordSetStringA(hrec, 1, "hoo");
1134 ok( r == ERROR_SUCCESS, "set string failed\n");
1135 sz = sizeof buffer;
1136 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1137 ok( sz == 8, "size wrong\n");
1138 ok( 0 == strcmp(buffer,"{{ {hoo}"), "wrong output\n");
1139 ok( r == ERROR_SUCCESS, "format failed\n");
1140
1141 r = MsiRecordSetStringA(hrec, 0, "{{ {[1]}");
1142 ok( r == ERROR_SUCCESS, "set string failed\n");
1143 r = MsiRecordSetStringA(hrec, 1, "hoo");
1144 ok( r == ERROR_SUCCESS, "set string failed\n");
1145 sz = sizeof buffer;
1146 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1147 ok( sz == 8, "size wrong\n");
1148 ok( 0 == strcmp(buffer,"{{ {hoo}"), "wrong output\n");
1149 ok( r == ERROR_SUCCESS, "format failed\n");
1150
1151 r = MsiRecordSetStringA(hrec, 0, "{{ {{[1]}");
1152 ok( r == ERROR_SUCCESS, "set string failed\n");
1153 r = MsiRecordSetStringA(hrec, 1, "hoo");
1154 ok( r == ERROR_SUCCESS, "set string failed\n");
1155 sz = sizeof buffer;
1156 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1157 ok( sz == 9, "size wrong\n");
1158 ok( 0 == strcmp(buffer,"{{ {{hoo}"), "wrong output\n");
1159 ok( r == ERROR_SUCCESS, "format failed\n");
1160
1161 r = MsiRecordSetStringA(hrec, 0, "[1]}");
1162 ok( r == ERROR_SUCCESS, "set string failed\n");
1163 r = MsiRecordSetStringA(hrec, 1, "hoo");
1164 ok( r == ERROR_SUCCESS, "set string failed\n");
1165 sz = sizeof buffer;
1166 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1167 ok( sz == 4, "size wrong\n");
1168 ok( 0 == strcmp(buffer,"hoo}"), "wrong output\n");
1169 ok( r == ERROR_SUCCESS, "format failed\n");
1170
1171 r = MsiRecordSetStringA(hrec, 0, "{{ {{a}");
1172 ok( r == ERROR_SUCCESS, "set string failed\n");
1173 sz = sizeof buffer;
1174 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1175 ok( sz == 7, "size wrong\n");
1176 ok( 0 == strcmp(buffer,"{{ {{a}"), "wrong output\n");
1177 ok( r == ERROR_SUCCESS, "format failed\n");
1178
1179 r = MsiRecordSetStringA(hrec, 0, "{{ {{a}");
1180 ok( r == ERROR_SUCCESS, "set string failed\n");
1181 sz = sizeof buffer;
1182 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1183 ok( sz == 7, "size wrong\n");
1184 ok( 0 == strcmp(buffer,"{{ {{a}"), "wrong output\n");
1185 ok( r == ERROR_SUCCESS, "format failed\n");
1186
1187 r = MsiRecordSetStringA(hrec, 0, "0{1{2{3{4[1]5}6}7}8}9");
1188 ok( r == ERROR_SUCCESS, "set string failed\n");
1189 r = MsiRecordSetStringA(hrec, 1, "hoo");
1190 ok( r == ERROR_SUCCESS, "set string failed\n");
1191 sz = sizeof buffer;
1192 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1193 todo_wine
1194 {
1195 ok( sz == 19, "size wrong\n");
1196 ok( 0 == strcmp(buffer,"01{2{3{4hoo56}7}8}9"), "wrong output\n");
1197 }
1198 ok( r == ERROR_SUCCESS, "format failed\n");
1199
1200 r = MsiRecordSetStringA(hrec, 0, "0{1{2[1]3}4");
1201 ok( r == ERROR_SUCCESS, "set string failed\n");
1202 r = MsiRecordSetStringA(hrec, 1, "hoo");
1203 ok( r == ERROR_SUCCESS, "set string failed\n");
1204 sz = sizeof buffer;
1205 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1206 todo_wine
1207 {
1208 ok( sz == 9, "size wrong\n");
1209 ok( 0 == strcmp(buffer,"01{2hoo34"), "wrong output\n");
1210 }
1211 ok( r == ERROR_SUCCESS, "format failed\n");
1212
1213 r = MsiRecordSetStringA(hrec, 0, "0{1{2[1]3}4");
1214 ok( r == ERROR_SUCCESS, "set string failed\n");
1215 r = MsiRecordSetStringA(hrec, 1, "hoo");
1216 ok( r == ERROR_SUCCESS, "set string failed\n");
1217 sz = sizeof buffer;
1218 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1219 todo_wine
1220 {
1221 ok( sz == 9, "size wrong\n");
1222 ok( 0 == strcmp(buffer,"01{2hoo34"), "wrong output\n");
1223 }
1224 ok( r == ERROR_SUCCESS, "format failed\n");
1225
1226 r = MsiRecordSetStringA(hrec, 0, "{[1.} [1]");
1227 ok( r == ERROR_SUCCESS, "set string failed\n");
1228 r = MsiRecordSetStringA(hrec, 1, "hoo");
1229 ok( r == ERROR_SUCCESS, "set string failed\n");
1230 sz = sizeof buffer;
1231 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1232 ok( sz == 9, "size wrong\n");
1233 todo_wine
1234 {
1235 ok( 0 == strcmp(buffer,"{[1.} hoo"), "wrong output\n");
1236 }
1237 ok( r == ERROR_SUCCESS, "format failed\n");
1238
1239 r = MsiRecordSetStringA(hrec, 0, "{[{[1]}]}");
1240 ok( r == ERROR_SUCCESS, "set string failed\n");
1241 r = MsiRecordSetStringA(hrec, 1, "2");
1242 ok( r == ERROR_SUCCESS, "set string failed\n");
1243 r = MsiRecordSetStringA(hrec, 2, "foo");
1244 ok( r == ERROR_SUCCESS, "set string failed\n");
1245 sz = sizeof buffer;
1246 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1247 todo_wine
1248 {
1249 ok( sz == 9, "size wrong\n");
1250 ok( 0 == strcmp(buffer,"{[{[1]}]}"), "wrong output\n");
1251 }
1252 ok( r == ERROR_SUCCESS, "format failed\n");
1253
1254 r = MsiRecordSetStringA(hrec, 0, "{[1][}");
1255 ok( r == ERROR_SUCCESS, "set string failed\n");
1256 r = MsiRecordSetStringA(hrec, 1, "2");
1257 ok( r == ERROR_SUCCESS, "set string failed\n");
1258 r = MsiRecordSetStringA(hrec, 2, "foo");
1259 ok( r == ERROR_SUCCESS, "set string failed\n");
1260 sz = sizeof buffer;
1261 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1262 todo_wine
1263 {
1264 ok( sz == 2, "size wrong\n");
1265 ok( 0 == strcmp(buffer,"2["), "wrong output\n");
1266 }
1267 ok( r == ERROR_SUCCESS, "format failed\n");
1268
1269 r = MsiRecordSetStringA(hrec, 0, "[1]");
1270 ok( r == ERROR_SUCCESS, "set string failed\n");
1271 r = MsiRecordSetStringA(hrec, 1, "[2]");
1272 ok( r == ERROR_SUCCESS, "set string failed\n");
1273 r = MsiRecordSetStringA(hrec, 2, "foo");
1274 ok( r == ERROR_SUCCESS, "set string failed\n");
1275 sz = sizeof buffer;
1276 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1277 ok( sz == 3, "size wrong\n");
1278 ok( 0 == strcmp(buffer,"[2]"), "wrong output\n");
1279 ok( r == ERROR_SUCCESS, "format failed\n");
1280
1281 r = MsiRecordSetStringA(hrec, 0, "[{{boo}}1]");
1282 ok( r == ERROR_SUCCESS, "set string failed\n");
1283 r = MsiRecordSetStringA(hrec, 1, "hoo");
1284 ok( r == ERROR_SUCCESS, "set string failed\n");
1285 sz = sizeof buffer;
1286 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1287 ok( r == ERROR_SUCCESS, "format failed\n");
1288 ok( sz == 3, "size wrong\n");
1289 todo_wine
1290 {
1291 ok( 0 == strcmp(buffer,"[1]"), "wrong output: %s\n", buffer);
1292 }
1293
1294 r = MsiRecordSetStringA(hrec, 0, "[{{boo}}1]");
1295 ok( r == ERROR_SUCCESS, "set string failed\n");
1296 r = MsiRecordSetStringA(hrec, 0, "[1{{boo}}]");
1297 ok( r == ERROR_SUCCESS, "set string failed\n");
1298 r = MsiRecordSetStringA(hrec, 1, "hoo");
1299 ok( r == ERROR_SUCCESS, "set string failed\n");
1300 sz = sizeof buffer;
1301 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1302 ok( sz == 3, "size wrong\n");
1303 ok( 0 == strcmp(buffer,"[1]"), "wrong output\n");
1304 ok( r == ERROR_SUCCESS, "format failed\n");
1305
1306 r = MsiRecordSetStringA(hrec, 0, "{[1]{{boo} }}");
1307 ok( r == ERROR_SUCCESS, "set string failed\n");
1308 r = MsiRecordSetStringA(hrec, 1, "hoo");
1309 ok( r == ERROR_SUCCESS, "set string failed\n");
1310 sz = sizeof buffer;
1311 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1312 todo_wine
1313 {
1314 ok( sz == 11, "size wrong\n");
1315 ok( 0 == strcmp(buffer,"hoo{{boo }}"), "wrong output\n");
1316 }
1317 ok( r == ERROR_SUCCESS, "format failed\n");
1318
1319 r = MsiRecordSetStringA(hrec, 0, "{[1{{boo}}]}");
1320 ok( r == ERROR_SUCCESS, "set string failed\n");
1321 r = MsiRecordSetStringA(hrec, 1, "hoo");
1322 ok( r == ERROR_SUCCESS, "set string failed\n");
1323 sz = sizeof buffer;
1324 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1325 todo_wine
1326 {
1327 ok( sz == 12, "size wrong: got %u, expected 12\n", sz);
1328 ok( 0 == strcmp(buffer,"{[1{{boo}}]}"), "wrong output: got %s, expected [1]\n", buffer);
1329 }
1330 ok( r == ERROR_SUCCESS, "format failed\n");
1331
1332 r = MsiRecordSetStringA(hrec, 0, "{{[1]}");
1333 ok( r == ERROR_SUCCESS, "set string failed\n");
1334 r = MsiRecordSetStringA(hrec, 1, "hoo");
1335 ok( r == ERROR_SUCCESS, "set string failed\n");
1336 sz = sizeof buffer;
1337 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1338 ok( sz == 6, "size wrong: got %u, expected 3\n", sz);
1339 ok( 0 == strcmp(buffer,"{{hoo}"), "wrong output: got %s, expected [1]\n", buffer);
1340 ok( r == ERROR_SUCCESS, "format failed\n");
1341
1342 r = MsiRecordSetStringA(hrec, 0, "{[1{{bo}o}}]}");
1343 ok( r == ERROR_SUCCESS, "set string failed\n");
1344 r = MsiRecordSetStringA(hrec, 1, "hoo");
1345 ok( r == ERROR_SUCCESS, "set string failed\n");
1346 sz = sizeof buffer;
1347 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1348 ok( sz == 13, "size wrong\n");
1349 ok( 0 == strcmp(buffer,"{[1{{bo}o}}]}"), "wrong output %s\n",buffer);
1350 ok( r == ERROR_SUCCESS, "format failed\n");
1351
1352 r = MsiRecordSetStringA(hrec, 0, "{[1{{b{o}o}}]}");
1353 ok( r == ERROR_SUCCESS, "set string failed\n");
1354 sz = sizeof buffer;
1355 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1356 todo_wine
1357 {
1358 ok( sz == 14, "size wrong\n");
1359 ok( 0 == strcmp(buffer,"{[1{{b{o}o}}]}"), "wrong output %s\n",buffer);
1360 }
1361 ok( r == ERROR_SUCCESS, "format failed\n");
1362
1363 r = MsiRecordSetStringA(hrec, 0, "{ {[1]}");
1364 ok( r == ERROR_SUCCESS, "set string failed\n");
1365 r = MsiRecordSetStringA(hrec, 1, "hoo");
1366 ok( r == ERROR_SUCCESS, "set string failed\n");
1367 sz = sizeof buffer;
1368 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1369 todo_wine
1370 {
1371 ok( sz == 5, "size wrong\n");
1372 ok( 0 == strcmp(buffer," {hoo"), "wrong output %s\n",buffer);
1373 }
1374 ok( r == ERROR_SUCCESS, "format failed\n");
1375
1376 /* {} inside a substitution does strange things... */
1377 r = MsiRecordSetStringA(hrec, 0, "[[1]{}]");
1378 ok( r == ERROR_SUCCESS, "set string failed\n");
1379 r = MsiRecordSetStringA(hrec, 1, "2");
1380 ok( r == ERROR_SUCCESS, "set string failed\n");
1381 sz = sizeof buffer;
1382 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1383 todo_wine
1384 {
1385 ok( sz == 5, "size wrong\n");
1386 ok( 0 == strcmp(buffer,"[[1]]"), "wrong output %s\n",buffer);
1387 }
1388 ok( r == ERROR_SUCCESS, "format failed\n");
1389
1390 r = MsiRecordSetStringA(hrec, 0, "[[1]{}[1]]");
1391 ok( r == ERROR_SUCCESS, "set string failed\n");
1392 r = MsiRecordSetStringA(hrec, 1, "2");
1393 ok( r == ERROR_SUCCESS, "set string failed\n");
1394 sz = sizeof buffer;
1395 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1396 todo_wine
1397 {
1398 ok( sz == 6, "size wrong\n");
1399 ok( 0 == strcmp(buffer,"[[1]2]"), "wrong output %s\n",buffer);
1400 }
1401 ok( r == ERROR_SUCCESS, "format failed\n");
1402
1403 r = MsiRecordSetStringA(hrec, 0, "[a[1]b[1]c{}d[1]e]");
1404 ok( r == ERROR_SUCCESS, "set string failed\n");
1405 r = MsiRecordSetStringA(hrec, 1, "2");
1406 ok( r == ERROR_SUCCESS, "set string failed\n");
1407 sz = sizeof buffer;
1408 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1409 todo_wine
1410 {
1411 ok( sz == 14, "size wrong\n");
1412 ok( 0 == strcmp(buffer,"[a[1]b[1]cd2e]"), "wrong output %s\n",buffer);
1413 }
1414 ok( r == ERROR_SUCCESS, "format failed\n");
1415
1416 r = MsiRecordSetStringA(hrec, 0, "[a[1]b");
1417 ok( r == ERROR_SUCCESS, "set string failed\n");
1418 r = MsiRecordSetStringA(hrec, 1, "2");
1419 ok( r == ERROR_SUCCESS, "set string failed\n");
1420 sz = sizeof buffer;
1421 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1422 ok( sz == 6, "size wrong\n");
1423 ok( 0 == strcmp(buffer,"[a[1]b"), "wrong output %s\n",buffer);
1424 ok( r == ERROR_SUCCESS, "format failed\n");
1425
1426 r = MsiRecordSetStringA(hrec, 0, "a[1]b]");
1427 ok( r == ERROR_SUCCESS, "set string failed\n");
1428 r = MsiRecordSetStringA(hrec, 1, "2");
1429 ok( r == ERROR_SUCCESS, "set string failed\n");
1430 sz = sizeof buffer;
1431 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1432 ok( sz == 4, "size wrong\n");
1433 ok( 0 == strcmp(buffer,"a2b]"), "wrong output %s\n",buffer);
1434 ok( r == ERROR_SUCCESS, "format failed\n");
1435
1436 r = MsiRecordSetStringA(hrec, 0, "]a[1]b");
1437 ok( r == ERROR_SUCCESS, "set string failed\n");
1438 r = MsiRecordSetStringA(hrec, 1, "2");
1439 ok( r == ERROR_SUCCESS, "set string failed\n");
1440 sz = sizeof buffer;
1441 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1442 ok( sz == 4, "size wrong\n");
1443 ok( 0 == strcmp(buffer,"]a2b"), "wrong output %s\n",buffer);
1444 ok( r == ERROR_SUCCESS, "format failed\n");
1445
1446 r = MsiRecordSetStringA(hrec, 0, "]a[1]b");
1447 ok( r == ERROR_SUCCESS, "set string failed\n");
1448 r = MsiRecordSetStringA(hrec, 1, "2");
1449 ok( r == ERROR_SUCCESS, "set string failed\n");
1450 sz = sizeof buffer;
1451 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1452 ok( sz == 4, "size wrong\n");
1453 ok( 0 == strcmp(buffer,"]a2b"), "wrong output %s\n",buffer);
1454 ok( r == ERROR_SUCCESS, "format failed\n");
1455
1456 r = MsiRecordSetStringA(hrec, 0, "\\[1]");
1457 ok( r == ERROR_SUCCESS, "set string failed\n");
1458 r = MsiRecordSetStringA(hrec, 1, "2");
1459 ok( r == ERROR_SUCCESS, "set string failed\n");
1460 sz = sizeof buffer;
1461 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1462 ok( sz == 2, "size wrong\n");
1463 ok( 0 == strcmp(buffer,"\\2"), "wrong output %s\n",buffer);
1464 ok( r == ERROR_SUCCESS, "format failed\n");
1465
1466 r = MsiRecordSetStringA(hrec, 0, "\\{[1]}");
1467 ok( r == ERROR_SUCCESS, "set string failed\n");
1468 r = MsiRecordSetStringA(hrec, 1, "2");
1469 ok( r == ERROR_SUCCESS, "set string failed\n");
1470 sz = sizeof buffer;
1471 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1472 ok( sz == 2, "size wrong\n");
1473 ok( 0 == strcmp(buffer,"\\2"), "wrong output %s\n",buffer);
1474 ok( r == ERROR_SUCCESS, "format failed\n");
1475
1476 r = MsiRecordSetStringA(hrec, 0, "a{b[1]c}d");
1477 ok( r == ERROR_SUCCESS, "set string failed\n");
1478 r = MsiRecordSetStringA(hrec, 1, NULL);
1479 ok( r == ERROR_SUCCESS, "set string failed\n");
1480 sz = sizeof buffer;
1481 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1482 ok( sz == 2, "size wrong\n");
1483 ok( 0 == strcmp(buffer,"ad"), "wrong output %s\n",buffer);
1484 ok( r == ERROR_SUCCESS, "format failed\n");
1485
1486 r = MsiRecordSetStringA(hrec, 0, "{a[0]b}");
1487 ok( r == ERROR_SUCCESS, "set string failed\n");
1488 r = MsiRecordSetStringA(hrec, 1, "foo");
1489 ok( r == ERROR_SUCCESS, "set string failed\n");
1490 sz = sizeof buffer;
1491 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1492 ok( sz == 9, "size wrong\n");
1493 ok( 0 == strcmp(buffer,"a{a[0]b}b"), "wrong output %s\n",buffer);
1494 ok( r == ERROR_SUCCESS, "format failed\n");
1495
1496 r = MsiRecordSetStringA(hrec, 0, "[foo]");
1497 ok( r == ERROR_SUCCESS, "set string failed\n");
1498 sz = sizeof buffer;
1499 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1500 ok( sz == 5, "size wrong\n");
1501 ok( 0 == strcmp(buffer,"[foo]"), "wrong output %s\n",buffer);
1502 ok( r == ERROR_SUCCESS, "format failed\n");
1503
1504 r = MsiRecordSetStringA(hrec, 0, "{[1][-1][1]}");
1505 ok( r == ERROR_SUCCESS, "set string failed\n");
1506 r = MsiRecordSetStringA(hrec, 1, "foo");
1507 ok( r == ERROR_SUCCESS, "set string failed\n");
1508 sz = sizeof buffer;
1509 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1510 todo_wine
1511 {
1512 ok( sz == 12, "size wrong\n");
1513 ok( 0 == strcmp(buffer,"{foo[-1]foo}"), "wrong output %s\n",buffer);
1514 }
1515 ok( r == ERROR_SUCCESS, "format failed\n");
1516
1517 /* nested braces */
1518 sz = sizeof buffer;
1519 r = MsiRecordSetStringA(hrec, 0, "{abcd}");
1520 ok( r == ERROR_SUCCESS, "set string failed\n");
1521 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1522 ok( r == ERROR_SUCCESS, "format failed\n");
1523 ok( sz == 6, "size wrong(%i)\n",sz);
1524 ok( 0 == strcmp(buffer,"{abcd}"), "wrong output (%s)\n",buffer);
1525
1526 sz = sizeof buffer;
1527 r = MsiRecordSetStringA(hrec, 0, "{a[one]bc[two]de[one]f}");
1528 ok( r == ERROR_SUCCESS, "set string failed\n");
1529 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1530 ok( r == ERROR_SUCCESS, "format failed\n");
1531 ok( sz == 23, "size wrong(%i)\n",sz);
1532 ok( 0 == strcmp(buffer,"{a[one]bc[two]de[one]f}"), "wrong output (%s)\n",buffer);
1533
1534 sz = sizeof buffer;
1535 r = MsiRecordSetStringA(hrec, 0, "{a[one]bc[bad]de[two]f}");
1536 ok( r == ERROR_SUCCESS, "set string failed\n");
1537 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1538 ok( r == ERROR_SUCCESS, "format failed\n");
1539 ok( sz == 23, "size wrong(%i)\n",sz);
1540 ok( 0 == strcmp(buffer,"{a[one]bc[bad]de[two]f}"), "wrong output (%s)\n",buffer);
1541
1542 sz = sizeof buffer;
1543 r = MsiRecordSetStringA(hrec, 0, "{[bad]}");
1544 ok( r == ERROR_SUCCESS, "set string failed\n");
1545 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1546 ok( r == ERROR_SUCCESS, "format failed\n");
1547 ok( sz == 7, "size wrong(%i)\n",sz);
1548 ok( 0 == strcmp(buffer,"{[bad]}"), "wrong output (%s)\n",buffer);
1549
1550 sz = sizeof buffer;
1551 r = MsiRecordSetStringA(hrec, 0, "{abc{d[one]ef}"); /* missing final brace */
1552 ok( r == ERROR_SUCCESS, "set string failed\n");
1553 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1554 ok( r == ERROR_SUCCESS, "format failed\n");
1555 ok( sz == 14, "size wrong(%i)\n",sz);
1556 ok( 0 == strcmp(buffer,"{abc{d[one]ef}"), "wrong output (%s)\n",buffer);
1557
1558 sz = sizeof buffer;
1559 r = MsiRecordSetStringA(hrec, 0, "{abc{d[one]ef}}");
1560 ok( r == ERROR_SUCCESS, "set string failed\n");
1561 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1562 ok( r == ERROR_SUCCESS, "format failed\n");
1563 ok( sz == 15, "size wrong(%i)\n",sz);
1564 ok( 0 == strcmp(buffer,"{abc{d[one]ef}}"), "wrong output (%s)\n",buffer);
1565
1566 sz = sizeof buffer;
1567 r = MsiRecordSetStringA(hrec, 0, "{abc}{{def}hi{j[one]k}}");
1568 ok( r == ERROR_SUCCESS, "set string failed\n");
1569 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1570 ok( r == ERROR_SUCCESS, "format failed\n");
1571 ok( sz == 5, "size wrong(%i)\n",sz);
1572 ok( 0 == strcmp(buffer,"{abc}"), "wrong output (%s)\n",buffer);
1573
1574 sz = sizeof buffer;
1575 r = MsiRecordSetStringA(hrec, 0, "{{def}hi{j[one]k}}");
1576 ok( r == ERROR_SUCCESS, "set string failed\n");
1577 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1578 ok( r == ERROR_SUCCESS, "format failed\n");
1579 ok( sz == 0, "size wrong(%i)\n",sz);
1580 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
1581
1582 sz = sizeof buffer;
1583 r = MsiRecordSetStringA(hrec, 0, "{{def}hi{jk}}");
1584 ok( r == ERROR_SUCCESS, "set string failed\n");
1585 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1586 ok( r == ERROR_SUCCESS, "format failed\n");
1587 ok( sz == 0, "size wrong(%i)\n",sz);
1588 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
1589
1590 sz = sizeof buffer;
1591 r = MsiRecordSetStringA(hrec, 0, "{{{def}}hi{jk}}");
1592 ok( r == ERROR_SUCCESS, "set string failed\n");
1593 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1594 ok( r == ERROR_SUCCESS, "format failed\n");
1595 todo_wine
1596 {
1597 ok( sz == 7, "size wrong(%i)\n",sz);
1598 ok( 0 == strcmp(buffer,"hi{jk}}"), "wrong output (%s)\n",buffer);
1599 }
1600
1601 sz = sizeof buffer;
1602 r = MsiRecordSetStringA(hrec, 0, "{{def}hi{{jk}}}");
1603 ok( r == ERROR_SUCCESS, "set string failed\n");
1604 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1605 ok( r == ERROR_SUCCESS, "format failed\n");
1606 todo_wine
1607 {
1608 ok( sz == 1, "size wrong(%i)\n",sz);
1609 ok( 0 == strcmp(buffer,"}"), "wrong output (%s)\n",buffer);
1610 }
1611
1612 sz = sizeof buffer;
1613 r = MsiRecordSetStringA(hrec, 0, "{{def}{jk}}");
1614 ok( r == ERROR_SUCCESS, "set string failed\n");
1615 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1616 ok( r == ERROR_SUCCESS, "format failed\n");
1617 ok( sz == 0, "size wrong(%i)\n",sz);
1618 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
1619
1620 sz = sizeof buffer;
1621 r = MsiRecordSetStringA(hrec, 0, "{{def}}");
1622 ok( r == ERROR_SUCCESS, "set string failed\n");
1623 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1624 ok( r == ERROR_SUCCESS, "format failed\n");
1625 ok( sz == 0, "size wrong(%i)\n",sz);
1626 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
1627
1628 sz = sizeof buffer;
1629 r = MsiRecordSetStringA(hrec, 0, "{a{b}c}");
1630 ok( r == ERROR_SUCCESS, "set string failed\n");
1631 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1632 ok( r == ERROR_SUCCESS, "format failed\n");
1633 ok( sz == 7, "size wrong(%i)\n",sz);
1634 ok( 0 == strcmp(buffer,"{a{b}c}"), "wrong output (%s)\n",buffer);
1635
1636 sz = sizeof buffer;
1637 r = MsiRecordSetStringA(hrec, 0, "{a{b}}");
1638 ok( r == ERROR_SUCCESS, "set string failed\n");
1639 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1640 ok( r == ERROR_SUCCESS, "format failed\n");
1641 ok( sz == 6, "size wrong(%i)\n",sz);
1642 ok( 0 == strcmp(buffer,"{a{b}}"), "wrong output (%s)\n",buffer);
1643
1644 sz = sizeof buffer;
1645 r = MsiRecordSetStringA(hrec, 0, "{{b}c}");
1646 ok( r == ERROR_SUCCESS, "set string failed\n");
1647 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1648 ok( r == ERROR_SUCCESS, "format failed\n");
1649 ok( sz == 6, "size wrong(%i)\n",sz);
1650 ok( 0 == strcmp(buffer,"{{b}c}"), "wrong output (%s)\n",buffer);
1651
1652 sz = sizeof buffer;
1653 r = MsiRecordSetStringA(hrec, 0, "{{{{}}}}");
1654 ok( r == ERROR_SUCCESS, "set string failed\n");
1655 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1656 ok( r == ERROR_SUCCESS, "format failed\n");
1657 todo_wine
1658 {
1659 ok( sz == 2, "size wrong(%i)\n",sz);
1660 ok( 0 == strcmp(buffer,"}}"), "wrong output (%s)\n",buffer);
1661 }
1662
1663 sz = sizeof buffer;
1664 MsiRecordSetInteger(hrec, 1, 100);
1665 MsiRecordSetInteger(hrec, 2, -100);
1666 r = MsiRecordSetStringA(hrec, 0, "[1] [2]");
1667 ok( r == ERROR_SUCCESS, "set string failed\n");
1668 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1669 ok( r == ERROR_SUCCESS, "format failed\n");
1670 ok( sz == 8, "size wrong(%i)\n",sz);
1671 ok( 0 == strcmp(buffer,"100 -100"), "wrong output (%s)\n",buffer);
1672
1673 sz = sizeof(buffer);
1674 r = MsiRecordSetStringA(hrec, 0, "[1] {[noprop] [twoprop]} {abcdef}");
1675 ok( r == ERROR_SUCCESS, "set string failed\n");
1676 r = MsiRecordSetStringA(hrec, 1, "one");
1677 ok( r == ERROR_SUCCESS, "set string failed\n");
1678 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1679 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1680 ok(sz == 33, "Expected 33, got %d\n",sz);
1681 ok(!lstrcmpA(buffer, "one {[noprop] [twoprop]} {abcdef}"),
1682 "Expected \"one {[noprop] [twoprop]} {abcdef}\", got \"%s\"\n", buffer);
1683
1684 sz = sizeof(buffer);
1685 r = MsiRecordSetStringA(hrec, 0, "[1] {[noprop] [one]} {abcdef}");
1686 ok( r == ERROR_SUCCESS, "set string failed\n");
1687 r = MsiRecordSetStringA(hrec, 1, "one");
1688 ok( r == ERROR_SUCCESS, "set string failed\n");
1689 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1690 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1691 ok(sz == 29, "Expected 29, got %d\n",sz);
1692 ok(!lstrcmpA(buffer, "one {[noprop] [one]} {abcdef}"),
1693 "Expected \"one {[noprop] [one]} {abcdef}\", got \"%s\"\n", buffer);
1694
1695 sz = sizeof(buffer);
1696 r = MsiRecordSetStringA(hrec, 0, "[1] {[one]} {abcdef}");
1697 ok( r == ERROR_SUCCESS, "set string failed\n");
1698 r = MsiRecordSetStringA(hrec, 1, "one");
1699 ok( r == ERROR_SUCCESS, "set string failed\n");
1700 r = MsiFormatRecordA(0, hrec, buffer, &sz);
1701 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1702 ok(sz == 20, "Expected 20, got %d\n",sz);
1703 ok(!lstrcmpA(buffer, "one {[one]} {abcdef}"),
1704 "Expected \"one {[one]} {abcdef}\", got \"%s\"\n", buffer);
1705
1706 MsiCloseHandle( hrec );
1707 }
1708
1709 static void test_formatrecord_package(void)
1710 {
1711 char buffer[100];
1712 MSIHANDLE hrec;
1713 MSIHANDLE package;
1714 UINT r;
1715 DWORD sz=100;
1716
1717 r = helper_createpackage( msifile, &package );
1718 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1719 {
1720 skip("Not enough rights to perform tests\n");
1721 return;
1722 }
1723 ok( r == ERROR_SUCCESS, "Unable to create package %u\n", r );
1724
1725 hrec = MsiCreateRecord(12);
1726 ok( hrec, "failed to create record\n");
1727
1728 r = MsiFormatRecordA(package, 0, NULL, NULL );
1729 ok( r == ERROR_INVALID_HANDLE, "wrong error\n");
1730
1731 r = MsiFormatRecordA(package, hrec, NULL, NULL );
1732 ok( r == ERROR_SUCCESS, "format failed\n");
1733
1734 r = MsiRecordSetStringA(hrec,0,NULL);
1735 ok( r == ERROR_SUCCESS, "set string failed\n");
1736 r = MsiRecordSetStringA(hrec,1,NULL);
1737 ok( r == ERROR_SUCCESS, "set string failed\n");
1738 r = MsiRecordSetStringA(hrec,2,NULL);
1739 ok( r == ERROR_SUCCESS, "set string failed\n");
1740 r = MsiRecordSetStringA(hrec,3,NULL);
1741 ok( r == ERROR_SUCCESS, "set string failed\n");
1742 r = MsiRecordSetStringA(hrec,4,NULL);
1743 ok( r == ERROR_SUCCESS, "set string failed\n");
1744 r = MsiRecordSetStringA(hrec,5,NULL);
1745 ok( r == ERROR_SUCCESS, "set string failed\n");
1746 r = MsiRecordSetStringA(hrec,6,NULL);
1747 ok( r == ERROR_SUCCESS, "set string failed\n");
1748 r = MsiRecordSetStringA(hrec,7,NULL);
1749 ok( r == ERROR_SUCCESS, "set string failed\n");
1750 r = MsiRecordSetStringA(hrec,8,NULL);
1751 ok( r == ERROR_SUCCESS, "set string failed\n");
1752 r = MsiRecordSetStringA(hrec,9,NULL);
1753 ok( r == ERROR_SUCCESS, "set string failed\n");
1754 r = MsiRecordSetStringA(hrec,10,NULL);
1755 ok( r == ERROR_SUCCESS, "set string failed\n");
1756 r = MsiRecordSetStringA(hrec,11,NULL);
1757 ok( r == ERROR_SUCCESS, "set string failed\n");
1758 r = MsiRecordSetStringA(hrec,12,NULL);
1759 ok( r == ERROR_SUCCESS, "set string failed\n");
1760
1761 sz = sizeof buffer;
1762 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1763 ok( r == ERROR_SUCCESS, "format failed with empty buffer (%i)\n",r);
1764 ok( sz == 51, "size wrong (%i)\n",sz);
1765 ok( 0 == strcmp(buffer,"1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: "), "wrong output(%s)\n",buffer);
1766
1767 r = MsiSetPropertyA(package, "prop", "val");
1768 ok( r == ERROR_SUCCESS, "failed to set propertY: %d\n", r);
1769
1770 r = MsiRecordSetStringA(hrec, 0, NULL);
1771 ok( r == ERROR_SUCCESS, "set string failed\n");
1772 r = MsiRecordSetStringA(hrec, 1, "[2]");
1773 ok( r == ERROR_SUCCESS, "set string failed\n");
1774 r = MsiRecordSetStringA(hrec, 2, "stuff");
1775 ok( r == ERROR_SUCCESS, "set string failed\n");
1776 r = MsiRecordSetStringA(hrec, 3, "prop");
1777 ok( r == ERROR_SUCCESS, "set string failed\n");
1778 r = MsiRecordSetStringA(hrec, 4, "[prop]");
1779 ok( r == ERROR_SUCCESS, "set string failed\n");
1780 r = MsiRecordSetStringA(hrec, 5, "[noprop]");
1781 ok( r == ERROR_SUCCESS, "set string failed\n");
1782 sz = sizeof buffer;
1783 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1784 ok( r == ERROR_SUCCESS, "format failed with empty buffer (%i)\n",r);
1785 todo_wine
1786 {
1787 ok( sz == 66, "size wrong (%i)\n",sz);
1788 ok( !lstrcmpA(buffer,
1789 "1: [2] 2: stuff 3: prop 4: val 5: 6: 7: 8: 9: 10: 11: 12: "),
1790 "wrong output(%s)\n",buffer);
1791 }
1792
1793 /* now put play games with escaping */
1794 r = MsiRecordSetStringA(hrec, 0, "[1] [2] [\\3asdf]");
1795 ok( r == ERROR_SUCCESS, "set string failed\n");
1796 r = MsiRecordSetStringA(hrec, 1, "boo");
1797 ok( r == ERROR_SUCCESS, "set string failed\n");
1798 r = MsiRecordSetStringA(hrec, 2, "hoo");
1799 ok( r == ERROR_SUCCESS, "set string failed\n");
1800 sz = sizeof buffer;
1801 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1802 ok( r == ERROR_SUCCESS, "format failed\n");
1803 ok( sz == 9, "size wrong(%i)\n",sz);
1804 ok( 0 == strcmp(buffer,"boo hoo 3"), "wrong output (%s)\n",buffer);
1805
1806 r = MsiRecordSetStringA(hrec, 0, "[1] [2] [\\x]");
1807 ok( r == ERROR_SUCCESS, "set string failed\n");
1808 r = MsiRecordSetStringA(hrec, 1, "boo");
1809 ok( r == ERROR_SUCCESS, "set string failed\n");
1810 r = MsiRecordSetStringA(hrec, 2, "hoo");
1811 ok( r == ERROR_SUCCESS, "set string failed\n");
1812 sz = sizeof buffer;
1813 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1814 ok( r == ERROR_SUCCESS, "format failed\n");
1815 ok( sz == 9, "size wrong(%i)\n",sz);
1816 ok( 0 == strcmp(buffer,"boo hoo x"), "wrong output (%s)\n",buffer);
1817
1818 MsiRecordSetStringA(hrec, 0, "[\\x]");
1819 sz = sizeof buffer;
1820 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1821 ok( r == ERROR_SUCCESS, "format failed\n");
1822 ok( sz == 1, "size wrong: %d\n", sz);
1823 ok( 0 == strcmp(buffer,"x"), "wrong output: %s\n", buffer);
1824
1825 MsiRecordSetStringA(hrec, 0, "{\\x}");
1826 sz = sizeof buffer;
1827 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1828 ok( r == ERROR_SUCCESS, "format failed\n");
1829 ok( sz == 4, "size wrong: %d\n", sz);
1830 ok( 0 == strcmp(buffer,"{\\x}"), "wrong output: %s\n", buffer);
1831
1832 MsiRecordSetStringA(hrec, 0, "[abc\\x]");
1833 sz = sizeof buffer;
1834 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1835 ok( r == ERROR_SUCCESS, "format failed\n");
1836 ok( sz == 0, "size wrong: %d\n", sz);
1837 ok( 0 == strcmp(buffer,""), "wrong output: %s\n", buffer);
1838
1839 MsiRecordSetStringA(hrec, 0, "[abc\\xdef]");
1840 sz = sizeof buffer;
1841 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1842 ok( r == ERROR_SUCCESS, "format failed\n");
1843 ok( sz == 0, "size wrong: %d\n", sz);
1844 ok( 0 == strcmp(buffer,""), "wrong output: %s\n", buffer);
1845
1846 MsiRecordSetStringA(hrec, 0, "\\x");
1847 sz = sizeof(buffer);
1848 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1849 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1850 ok(sz == 2, "Expected 2, got %d\n", sz);
1851 ok(!lstrcmpA(buffer, "\\x"), "Expected \"\\x\", got \"%s\"\n", buffer);
1852
1853 MsiRecordSetStringA(hrec, 0, "[\\[");
1854 sz = sizeof(buffer);
1855 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1856 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1857 ok(sz == 3, "Expected 3, got %d\n", sz);
1858 ok(!lstrcmpA(buffer, "[\\["), "Expected \"[\\[\", got \"%s\"\n", buffer);
1859
1860 MsiRecordSetStringA(hrec, 0, "[\\[]");
1861 sz = sizeof(buffer);
1862 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1863 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1864 ok(sz == 1, "Expected 1, got %d\n", sz);
1865 ok(!lstrcmpA(buffer, "["), "Expected \"[\", got \"%s\"\n", buffer);
1866
1867 MsiRecordSetStringA(hrec, 0, "[[]");
1868 sz = sizeof(buffer);
1869 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1870 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1871 ok(sz == 3, "Expected 3, got %d\n", sz);
1872 ok(!lstrcmpA(buffer, "[[]"), "Expected \"[]\", got \"%s\"\n", buffer);
1873
1874 MsiRecordSetStringA(hrec, 0, "[\\[]]");
1875 sz = sizeof(buffer);
1876 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1877 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1878 ok(sz == 2, "Expected 2, got %d\n", sz);
1879 ok(!lstrcmpA(buffer, "[]"), "Expected \"[]\", got \"%s\"\n", buffer);
1880
1881 MsiRecordSetStringA(hrec, 0, "[\\[a]");
1882 sz = sizeof(buffer);
1883 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1884 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1885 ok(sz == 1, "Expected 1, got %d\n", sz);
1886 ok(!lstrcmpA(buffer, "["), "Expected \"[\", got \"%s\"\n", buffer);
1887
1888 MsiRecordSetStringA(hrec, 0, "[\\a[]");
1889 sz = sizeof(buffer);
1890 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1891 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1892 todo_wine
1893 {
1894 ok(sz == 1, "Expected 1, got %d\n", sz);
1895 ok(!lstrcmpA(buffer, "a"), "Expected \"a\", got \"%s\"\n", buffer);
1896 }
1897
1898 MsiRecordSetStringA(hrec, 0, "[prop]");
1899 sz = sizeof(buffer);
1900 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1901 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1902 ok(sz == 3, "Expected 3, got %d\n", sz);
1903 ok(!lstrcmpA(buffer, "val"), "Expected \"val\", got \"%s\"\n", buffer);
1904
1905 MsiRecordSetStringA(hrec, 0, "[prop] [pro\\pblah] [prop]");
1906 sz = sizeof(buffer);
1907 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1908 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1909 ok(sz == 8, "Expected 8, got %d\n", sz);
1910 ok(!lstrcmpA(buffer, "val val"), "Expected \"val val\", got \"%s\"\n", buffer);
1911
1912 MsiSetPropertyA(package, "b", "ball");
1913 MsiRecordSetStringA(hrec, 0, "[\\b]");
1914 sz = sizeof(buffer);
1915 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1916 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1917 ok(sz == 1, "Expected 1, got %d\n", sz);
1918 ok(!lstrcmpA(buffer, "b"), "Expected \"b\", got \"%s\"\n", buffer);
1919
1920 MsiRecordSetStringA(hrec, 0, "[\\c]");
1921 sz = sizeof(buffer);
1922 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1923 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1924 ok(sz == 1, "Expected 1, got %d\n", sz);
1925 ok(!lstrcmpA(buffer, "c"), "Expected \"c\", got \"%s\"\n", buffer);
1926
1927 MsiRecordSetStringA(hrec, 0, "[\\[]prop]");
1928 sz = sizeof(buffer);
1929 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1930 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1931 ok(sz == 6, "Expected 6, got %d\n", sz);
1932 ok(!lstrcmpA(buffer, "[prop]"), "Expected \"[prop]\", got \"%s\"\n", buffer);
1933
1934 MsiRecordSetStringA(hrec, 0, "[\\a]prop]");
1935 sz = sizeof(buffer);
1936 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1937 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1938 ok(sz == 6, "Expected 6, got %d\n", sz);
1939 ok(!lstrcmpA(buffer, "aprop]"), "Expected \"aprop]\", got \"%s\"\n", buffer);
1940
1941 MsiRecordSetStringA(hrec, 0, "[\\[]Bracket Text[\\]]");
1942 sz = sizeof buffer;
1943 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1944 ok( r == ERROR_SUCCESS, "format failed\n");
1945 ok( sz == 14, "size wrong: %d\n", sz);
1946 ok( 0 == strcmp(buffer,"[Bracket Text]"), "wrong output: %s\n", buffer);
1947
1948 /* null characters */
1949 r = MsiRecordSetStringA(hrec, 0, "[1] [~] [2]");
1950 ok( r == ERROR_SUCCESS, "set string failed\n");
1951 r = MsiRecordSetStringA(hrec, 1, "boo");
1952 ok( r == ERROR_SUCCESS, "set string failed\n");
1953 r = MsiRecordSetStringA(hrec, 2, "hoo");
1954 ok( r == ERROR_SUCCESS, "set string failed\n");
1955 sz = sizeof buffer;
1956 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1957 ok( r == ERROR_SUCCESS, "format failed\n");
1958 ok( sz == 9, "size wrong: %d\n", sz);
1959 ok( 0 == strcmp(buffer,"boo "), "wrong output: %s\n", buffer);
1960 ok(!lstrcmpA(&buffer[5], " hoo"),
1961 "Expected \" hoo\", got \"%s\"\n", &buffer[5]);
1962
1963 r = MsiRecordSetStringA(hrec, 0, "[1] [~abc] [2]");
1964 ok( r == ERROR_SUCCESS, "set string failed\n");
1965 r = MsiRecordSetStringA(hrec, 1, "boo");
1966 ok( r == ERROR_SUCCESS, "set string failed\n");
1967 r = MsiRecordSetStringA(hrec, 2, "hoo");
1968 ok( r == ERROR_SUCCESS, "set string failed\n");
1969 sz = sizeof(buffer);
1970 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1971 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1972 ok(sz == 8, "Expected 8, got %d\n", sz);
1973 ok(!lstrcmpA(buffer, "boo hoo"), "Expected \"boo hoo\", got \"%s\"\n", buffer);
1974
1975 /* properties */
1976 r = MsiSetPropertyA(package,"dummy","Bork");
1977 ok( r == ERROR_SUCCESS, "set property failed\n");
1978 r = MsiRecordSetStringA(hrec, 0, "[1] [dummy] [2]");
1979 ok( r == ERROR_SUCCESS, "set string failed\n");
1980 r = MsiRecordSetStringA(hrec, 1, "boo");
1981 ok( r == ERROR_SUCCESS, "set string failed\n");
1982 r = MsiRecordSetStringA(hrec, 2, "hoo");
1983 ok( r == ERROR_SUCCESS, "set string failed\n");
1984 sz = sizeof buffer;
1985 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1986 ok( r == ERROR_SUCCESS, "format failed\n");
1987 ok( sz == 12, "size wrong\n");
1988 ok( 0 == strcmp(buffer,"boo Bork hoo"), "wrong output\n");
1989
1990 r = MsiRecordSetStringA(hrec, 0, "[1] [invalid] [2]");
1991 ok( r == ERROR_SUCCESS, "set string failed\n");
1992 r = MsiRecordSetStringA(hrec, 1, "boo");
1993 ok( r == ERROR_SUCCESS, "set string failed\n");
1994 r = MsiRecordSetStringA(hrec, 2, "hoo");
1995 ok( r == ERROR_SUCCESS, "set string failed\n");
1996 sz = sizeof buffer;
1997 r = MsiFormatRecordA(package, hrec, buffer, &sz);
1998 ok( r == ERROR_SUCCESS, "format failed\n");
1999 ok( sz == 8, "size wrong\n");
2000 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
2001
2002 /* nesting tests */
2003 r = MsiSetPropertyA(package,"dummya","foo");
2004 ok( r == ERROR_SUCCESS, "set string failed\n");
2005 r = MsiSetPropertyA(package,"dummyb","baa");
2006 ok( r == ERROR_SUCCESS, "set string failed\n");
2007 r = MsiSetPropertyA(package,"adummyc","whoa");
2008 ok( r == ERROR_SUCCESS, "set property failed\n");
2009 r = MsiRecordSetStringA(hrec, 0, "[dummy[1]] [dummy[2]] [[1]dummy[3]]");
2010 ok( r == ERROR_SUCCESS, "set string failed\n");
2011 r = MsiRecordSetStringA(hrec, 1, "a");
2012 ok( r == ERROR_SUCCESS, "set string failed\n");
2013 r = MsiRecordSetStringA(hrec, 2, "b");
2014 ok( r == ERROR_SUCCESS, "set string failed\n");
2015 r = MsiRecordSetStringA(hrec, 3, "c");
2016 ok( r == ERROR_SUCCESS, "set string failed\n");
2017 sz = sizeof buffer;
2018 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2019 ok( r == ERROR_SUCCESS, "format failed\n");
2020 ok( sz == 12, "size wrong(%i)\n",sz);
2021 ok( 0 == strcmp(buffer,"foo baa whoa"), "wrong output (%s)\n",buffer);
2022
2023 r = MsiSetPropertyA(package,"dummya","1");
2024 ok( r == ERROR_SUCCESS, "set property failed\n");
2025 r = MsiSetPropertyA(package,"dummyb","[2]");
2026 ok( r == ERROR_SUCCESS, "set property failed\n");
2027 r = MsiRecordSetStringA(hrec, 0, "[dummya] [[dummya]] [dummyb]");
2028 ok( r == ERROR_SUCCESS, "set string failed\n");
2029 r = MsiRecordSetStringA(hrec, 1, "aaa");
2030 ok( r == ERROR_SUCCESS, "set string failed\n");
2031 r = MsiRecordSetStringA(hrec, 2, "bbb");
2032 ok( r == ERROR_SUCCESS, "set string failed\n");
2033 r = MsiRecordSetStringA(hrec, 3, "ccc");
2034 ok( r == ERROR_SUCCESS, "set string failed\n");
2035 sz = sizeof buffer;
2036 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2037 ok( r == ERROR_SUCCESS, "format failed\n");
2038 todo_wine
2039 {
2040 ok( sz == 9, "size wrong(%i)\n",sz);
2041 ok( 0 == strcmp(buffer,"1 [1] [2]"), "wrong output (%s)\n",buffer);
2042 }
2043
2044 r = MsiSetPropertyA(package,"dummya","1");
2045 ok( r == ERROR_SUCCESS, "set property failed\n");
2046 r = MsiSetPropertyA(package,"dummyb","a");
2047 ok( r == ERROR_SUCCESS, "set property failed\n");
2048 r = MsiSetPropertyA(package,"dummyc","\\blath");
2049 ok( r == ERROR_SUCCESS, "set property failed\n");
2050 r = MsiSetPropertyA(package,"dummyd","[\\blath]");
2051 ok( r == ERROR_SUCCESS, "set property failed\n");
2052 r = MsiRecordSetStringA(hrec, 0, "[dummyc] [[dummyc]] [dummy[dummyb]]");
2053 ok( r == ERROR_SUCCESS, "set string failed\n");
2054 r = MsiRecordSetStringA(hrec, 1, "aaa");
2055 ok( r == ERROR_SUCCESS, "set string failed\n");
2056 r = MsiRecordSetStringA(hrec, 2, "bbb");
2057 ok( r == ERROR_SUCCESS, "set string failed\n");
2058 r = MsiRecordSetStringA(hrec, 3, "ccc");
2059 ok( r == ERROR_SUCCESS, "set string failed\n");
2060 sz = sizeof buffer;
2061 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2062 ok( r == ERROR_SUCCESS, "format failed\n");
2063 ok( sz == 10, "size wrong(%i)\n",sz);
2064 ok( 0 == strcmp(buffer,"\\blath b 1"), "wrong output (%s)\n",buffer);
2065
2066 r = MsiRecordSetStringA(hrec, 0, "[1] [2] [[\\3asdf]]");
2067 ok( r == ERROR_SUCCESS, "set string failed\n");
2068 r = MsiRecordSetStringA(hrec, 1, "boo");
2069 ok( r == ERROR_SUCCESS, "set string failed\n");
2070 r = MsiRecordSetStringA(hrec, 2, "hoo");
2071 ok( r == ERROR_SUCCESS, "set string failed\n");
2072 r = MsiRecordSetStringA(hrec, 3, "yeah");
2073 ok( r == ERROR_SUCCESS, "set string failed\n");
2074 sz = sizeof buffer;
2075 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2076 ok( r == ERROR_SUCCESS, "format failed\n");
2077 todo_wine
2078 {
2079 ok( sz == 11, "size wrong(%i)\n",sz);
2080 ok( 0 == strcmp(buffer,"boo hoo [3]"), "wrong output (%s)\n",buffer);
2081 }
2082
2083 r = MsiRecordSetStringA(hrec, 0, "[1] [2] [[3]]");
2084 ok( r == ERROR_SUCCESS, "set string failed\n");
2085 r = MsiRecordSetStringA(hrec, 1, "boo");
2086 ok( r == ERROR_SUCCESS, "set string failed\n");
2087 r = MsiRecordSetStringA(hrec, 2, "hoo");
2088 ok( r == ERROR_SUCCESS, "set string failed\n");
2089 r = MsiRecordSetStringA(hrec, 3, "\\help");
2090 ok( r == ERROR_SUCCESS, "set string failed\n");
2091 sz = sizeof buffer;
2092 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2093 ok( r == ERROR_SUCCESS, "format failed\n");
2094 ok( sz == 9, "size wrong(%i)\n",sz);
2095 ok( 0 == strcmp(buffer,"boo hoo h"), "wrong output (%s)\n",buffer);
2096
2097 /* nested properties */
2098 MsiSetPropertyA(package, "PropA", "surprise");
2099 MsiSetPropertyA(package, "PropB", "[PropA]");
2100 MsiSetPropertyA(package, "PropC", "[PropB]");
2101 sz = sizeof buffer;
2102 MsiRecordSetStringA(hrec, 0, "[PropC]");
2103 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2104 ok( r == ERROR_SUCCESS, "format failed\n");
2105 ok( sz == 7, "size wrong(%i)\n",sz);
2106 ok( 0 == strcmp(buffer,"[PropB]"), "wrong output (%s)\n",buffer);
2107
2108 MsiSetPropertyA(package, "PropA", "surprise");
2109 MsiSetPropertyA(package, "PropB", "PropA");
2110 MsiSetPropertyA(package, "PropC", "PropB");
2111 sz = sizeof buffer;
2112 MsiRecordSetStringA(hrec, 0, "[PropC]");
2113 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2114 ok( r == ERROR_SUCCESS, "format failed\n");
2115 ok( sz == 5, "size wrong(%i)\n",sz);
2116 ok( 0 == strcmp(buffer,"PropB"), "wrong output (%s)\n",buffer);
2117
2118 MsiSetPropertyA(package, "PropA", "surprise");
2119 MsiSetPropertyA(package, "PropB", "[PropA]");
2120 MsiSetPropertyA(package, "PropC", "[PropB]");
2121 sz = sizeof buffer;
2122 MsiRecordSetStringA(hrec, 0, "[[PropC]]");
2123 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2124 ok( r == ERROR_SUCCESS, "format failed\n");
2125 ok( sz == 0, "size wrong(%i)\n",sz);
2126 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
2127
2128 MsiSetPropertyA(package, "PropA", "surprise");
2129 MsiSetPropertyA(package, "PropB", "[PropA]");
2130 MsiSetPropertyA(package, "PropC", "PropB");
2131 sz = sizeof buffer;
2132 MsiRecordSetStringA(hrec, 0, "[[PropC]]");
2133 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2134 ok( r == ERROR_SUCCESS, "format failed\n");
2135 ok( sz == 7, "size wrong(%i)\n",sz);
2136 ok( 0 == strcmp(buffer,"[PropA]"), "wrong output (%s)\n",buffer);
2137
2138 MsiSetPropertyA(package, "PropA", "surprise");
2139 MsiSetPropertyA(package, "PropB", "PropA");
2140 MsiSetPropertyA(package, "PropC", "PropB");
2141 sz = sizeof buffer;
2142 MsiRecordSetStringA(hrec, 0, "[[PropC]]");
2143 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2144 ok( r == ERROR_SUCCESS, "format failed\n");
2145 ok( sz == 5, "size wrong(%i)\n",sz);
2146 ok( 0 == strcmp(buffer,"PropA"), "wrong output (%s)\n",buffer);
2147
2148 MsiSetPropertyA(package, "PropA", "surprise");
2149 MsiSetPropertyA(package, "PropB", "PropA");
2150 MsiSetPropertyA(package, "PropC", "PropB");
2151 sz = sizeof buffer;
2152 MsiRecordSetStringA(hrec, 0, "[[[PropC]]]");
2153 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2154 ok( r == ERROR_SUCCESS, "format failed\n");
2155 ok( sz == 8, "size wrong(%i)\n",sz);
2156 ok( 0 == strcmp(buffer,"surprise"), "wrong output (%s)\n",buffer);
2157
2158 /* properties inside braces */
2159 sz = sizeof buffer;
2160 MsiRecordSetStringA(hrec, 0, "{abcd}");
2161 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2162 ok( r == ERROR_SUCCESS, "format failed\n");
2163 ok( sz == 6, "size wrong(%i)\n",sz);
2164 ok( 0 == strcmp(buffer,"{abcd}"), "wrong output (%s)\n",buffer);
2165
2166 MsiSetPropertyA(package, "one", "mercury");
2167 MsiSetPropertyA(package, "two", "venus");
2168 sz = sizeof buffer;
2169 MsiRecordSetStringA(hrec, 0, "{a[one]bc[two]de[one]f}");
2170 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2171 ok( r == ERROR_SUCCESS, "format failed: %d\n", r);
2172 ok( sz == 25, "size wrong(%i)\n",sz);
2173 ok( 0 == strcmp(buffer,"amercurybcvenusdemercuryf"), "wrong output (%s)\n",buffer);
2174
2175 MsiSetPropertyA(package, "one", "mercury");
2176 MsiSetPropertyA(package, "two", "venus");
2177 MsiSetPropertyA(package, "bad", "");
2178 sz = sizeof buffer;
2179 MsiRecordSetStringA(hrec, 0, "{a[one]bc[bad]de[two]f}");
2180 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2181 ok( r == ERROR_SUCCESS, "format failed\n");
2182 ok( sz == 0, "size wrong(%i)\n",sz);
2183 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
2184
2185 MsiSetPropertyA(package, "bad", "");
2186 sz = sizeof buffer;
2187 MsiRecordSetStringA(hrec, 0, "{[bad]}");
2188 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2189 ok( r == ERROR_SUCCESS, "format failed\n");
2190 ok( sz == 0, "size wrong(%i)\n",sz);
2191 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
2192
2193 MsiSetPropertyA(package, "one", "mercury");
2194 sz = sizeof buffer;
2195 MsiRecordSetStringA(hrec, 0, "{abc{d[one]ef}"); /* missing final brace */
2196 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2197 ok( r == ERROR_SUCCESS, "format failed\n");
2198 todo_wine
2199 {
2200 ok( sz == 14, "size wrong(%i)\n",sz);
2201 ok( 0 == strcmp(buffer,"abc{dmercuryef"), "wrong output (%s)\n",buffer);
2202 }
2203
2204 MsiSetPropertyA(package, "one", "mercury");
2205 sz = sizeof buffer;
2206 MsiRecordSetStringA(hrec, 0, "{abc{d[one]ef}}");
2207 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2208 ok( r == ERROR_SUCCESS, "format failed\n");
2209 todo_wine
2210 {
2211 ok( sz == 15, "size wrong(%i)\n",sz);
2212 ok( 0 == strcmp(buffer,"abc{dmercuryef}"), "wrong output (%s)\n",buffer);
2213 }
2214
2215 MsiSetPropertyA(package, "one", "mercury");
2216 sz = sizeof buffer;
2217 MsiRecordSetStringA(hrec, 0, "{abc}{{def}hi{j[one]k}}");
2218 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2219 ok( r == ERROR_SUCCESS, "format failed\n");
2220 ok( sz == 5, "size wrong(%i)\n",sz);
2221 ok( 0 == strcmp(buffer,"{abc}"), "wrong output (%s)\n",buffer);
2222
2223 MsiSetPropertyA(package, "one", "mercury");
2224
2225 sz = sizeof buffer;
2226 MsiRecordSetStringA(hrec, 0, "{{def}hi{j[one]k}}");
2227 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2228 ok( r == ERROR_SUCCESS, "format failed\n");
2229 ok( sz == 0, "size wrong(%i)\n",sz);
2230 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
2231
2232 sz = sizeof(buffer);
2233 MsiRecordSetStringA(hrec, 0, "[1] {[noprop] [twoprop]} {abcdef}");
2234 MsiRecordSetStringA(hrec, 1, "one");
2235 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2236 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2237 ok(sz == 13, "Expected 13, got %d\n",sz);
2238 ok(!lstrcmpA(buffer, "one {abcdef}"),
2239 "Expected \"one {abcdef}\", got \"%s\"\n", buffer);
2240
2241 sz = sizeof(buffer);
2242 MsiRecordSetStringA(hrec, 0, "[1] {[noprop] [one]} {abcdef}");
2243 MsiRecordSetStringA(hrec, 1, "one");
2244 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2245 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2246 ok(sz == 13, "Expected 13, got %d\n",sz);
2247 ok(!lstrcmpA(buffer, "one {abcdef}"),
2248 "Expected \"one {abcdef}\", got \"%s\"\n", buffer);
2249
2250 sz = sizeof(buffer);
2251 MsiRecordSetStringA(hrec, 0, "[1] {[one]} {abcdef}");
2252 MsiRecordSetStringA(hrec, 1, "one");
2253 r = MsiFormatRecordA(package, hrec, buffer, &sz);
2254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2255 ok(sz == 20, "Expected 20, got %d\n",sz);
2256 ok(!lstrcmpA(buffer, "one mercury {abcdef}"),
2257 "Expected \"one mercury {abcdef}\", got \"%s\"\n", buffer);
2258