2 * Copyright (C) 2005 Mike McCormack for CodeWeavers
3 * Copyright (C) 2005 Aric Stewart for CodeWeavers
5 * A test program for MSI record formatting
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
29 static MSIHANDLE helper_createpackage( const char *szName )
39 /* create an empty database */
40 res = MsiOpenDatabase(szName, MSIDBOPEN_CREATE, &hdb );
41 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
43 res = MsiDatabaseCommit( hdb );
44 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
46 /* build summmary info */
47 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
48 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
50 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
51 "Installation Database");
52 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
54 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
55 "Installation Database");
56 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
58 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
60 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
62 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
64 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
66 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
67 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
68 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
70 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
71 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
73 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
74 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
76 res = MsiSummaryInfoPersist(suminfo);
77 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
79 res = MsiCloseHandle( suminfo);
80 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
82 sprintf(szPackage,"#%li",(DWORD)hdb);
83 res = MsiOpenPackage(szPackage,&hPackage);
84 ok( res == ERROR_SUCCESS , "Failed to open package\n" );
86 res = MsiCloseHandle( hdb );
87 ok( res == ERROR_SUCCESS , "Failed to close database\n" );
92 static void test_createpackage(void)
94 static const CHAR filename[] = "winetest.msi";
95 MSIHANDLE hPackage = 0;
98 hPackage = helper_createpackage( filename );
99 ok ( hPackage != 0, " Failed to create package\n");
101 res = MsiCloseHandle( hPackage);
102 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
104 DeleteFile( filename );
107 static void test_formatrecord(void)
114 r = MsiFormatRecord(0, 0, NULL, NULL );
115 ok( r == ERROR_INVALID_HANDLE, "wrong error\n");
117 hrec = MsiCreateRecord(4);
118 ok( hrec, "failed to create record\n");
120 /* format an empty record */
121 r = MsiFormatRecord(0, hrec, NULL, NULL );
122 ok( r == ERROR_SUCCESS, "format failed\n");
126 r = MsiFormatRecord(0, hrec, buffer+1, &sz);
127 ok( r == ERROR_MORE_DATA && buffer[0] == 'x', "format failed measuring with buffer\n");
128 ok( sz == 16, "size wrong\n");
130 r = MsiFormatRecord(0, hrec, buffer, &sz);
131 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
132 ok( sz == 16, "size wrong\n");
133 ok( 0 == strcmp(buffer,"1: 2: 3: 4: "), "wrong output\n");
135 r = MsiCloseHandle(hrec);
136 ok(r==ERROR_SUCCESS, "Unable to close record\n");
138 hrec = MsiCreateRecord(6);
139 ok( hrec, "failed to create record\n");
144 r = MsiFormatRecord(0, hrec, buffer, &sz);
145 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
146 ok( sz == 24, "size wrong\n");
147 ok( 0 == strcmp(buffer,"1: 2: 3: 4: 5: 6: "), "wrong output\n");
150 /* format a format string with everything else empty */
151 r = MsiRecordSetString(hrec, 0, "%1");
152 ok( r == ERROR_SUCCESS, "set string failed\n");
153 r = MsiFormatRecord(0, hrec, NULL, NULL );
154 ok( r == ERROR_SUCCESS, "format failed\n");
155 r = MsiFormatRecord(0, hrec, buffer, NULL);
156 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
159 r = MsiFormatRecord(0, hrec, NULL, &sz);
160 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
161 ok( sz == 2, "size wrong (%li)\n",sz);
165 r = MsiFormatRecord(0, hrec, buffer, &sz);
166 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
167 ok( sz == 2, "size wrong\n");
168 ok( 0 == strcmp(buffer,"%1"), "wrong output\n");
170 /* make the buffer too small */
174 r = MsiFormatRecord(0, hrec, buffer, &sz);
175 ok( r == ERROR_MORE_DATA, "format failed with empty buffer\n");
176 ok( sz == 2, "size wrong\n");
177 ok( 0 == strcmp(buffer,"x"), "wrong output\n");
179 /* make the buffer a little bit bigger */
183 r = MsiFormatRecord(0, hrec, buffer, &sz);
184 ok( r == ERROR_MORE_DATA, "format failed with empty buffer\n");
185 ok( sz == 2, "size wrong\n");
186 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
192 r = MsiFormatRecord(0, hrec, buffer, &sz);
193 ok( r == ERROR_MORE_DATA, "format failed with empty buffer\n");
194 ok( sz == 2, "size wrong\n");
195 ok( 0 == strcmp(buffer,"%"), "wrong output\n");
201 r = MsiFormatRecord(0, hrec, buffer, &sz);
202 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
203 ok( sz == 2, "size wrong\n");
204 ok( 0 == strcmp(buffer,"%1"), "wrong output\n");
206 /* now try a real format string */
207 r = MsiRecordSetString(hrec, 0, "[1]");
208 ok( r == ERROR_SUCCESS, "set string failed\n");
210 r = MsiFormatRecord(0, hrec, buffer, &sz);
211 ok( r == ERROR_SUCCESS, "format failed\n");
212 ok( sz == 0, "size wrong\n");
213 ok( 0 == strcmp(buffer,""), "wrong output\n");
215 /* now put something in the first field */
216 r = MsiRecordSetString(hrec, 1, "boo hoo");
217 ok( r == ERROR_SUCCESS, "set string failed\n");
219 r = MsiFormatRecord(0, hrec, buffer, &sz);
220 ok( r == ERROR_SUCCESS, "format failed\n");
221 ok( sz == 7, "size wrong\n");
222 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
224 /* now put something in the first field */
225 r = MsiRecordSetString(hrec, 0, "[1] [2]");
226 r = MsiRecordSetString(hrec, 1, "boo");
227 r = MsiRecordSetString(hrec, 2, "hoo");
228 ok( r == ERROR_SUCCESS, "set string failed\n");
230 r = MsiFormatRecord(0, hrec, buffer, &sz);
231 ok( r == ERROR_SUCCESS, "format failed\n");
232 ok( sz == 7, "size wrong\n");
233 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
237 r = MsiRecordSetString(hrec, 0, "");
239 r = MsiFormatRecord(0, hrec, buffer, &sz);
240 ok( r == ERROR_SUCCESS, "format failed\n");
241 ok( sz == 30, "size wrong %li\n",sz);
242 ok( 0 == strcmp(buffer,"1: boo 2: hoo 3: 4: 5: 6: "),
243 "wrong output(%s)\n",buffer);
245 /* play games with recursive lookups */
246 r = MsiRecordSetString(hrec, 0, "[[1]] [2]");
247 r = MsiRecordSetString(hrec, 1, "2");
248 r = MsiRecordSetString(hrec, 2, "hey");
249 ok( r == ERROR_SUCCESS, "set string failed\n");
251 r = MsiFormatRecord(0, hrec, buffer, &sz);
252 ok( r == ERROR_SUCCESS, "format failed\n");
253 ok( sz == 7, "size wrong,(%li)\n",sz);
254 ok( 0 == strcmp(buffer,"hey hey"), "wrong output (%s)\n",buffer);
256 r = MsiRecordSetString(hrec, 0, "[[1]] [2]");
257 r = MsiRecordSetString(hrec, 1, "[2]");
258 r = MsiRecordSetString(hrec, 2, "hey");
259 ok( r == ERROR_SUCCESS, "set string failed\n");
261 r = MsiFormatRecord(0, hrec, buffer, &sz);
262 ok( r == ERROR_SUCCESS, "format failed\n");
263 ok( sz == 9, "size wrong,(%li)\n",sz);
264 ok( 0 == strcmp(buffer,"[[2]] hey"), "wrong output (%s)\n",buffer);
266 r = MsiRecordSetString(hrec, 0, "[[[3]]] [2]");
267 r = MsiRecordSetString(hrec, 1, "2");
268 r = MsiRecordSetString(hrec, 2, "hey");
269 r = MsiRecordSetString(hrec, 3, "1");
270 ok( r == ERROR_SUCCESS, "set string failed\n");
272 r = MsiFormatRecord(0, hrec, buffer, &sz);
273 ok( r == ERROR_SUCCESS, "format failed\n");
274 ok( sz == 7, "size wrong,(%li)\n",sz);
275 ok( 0 == strcmp(buffer,"hey hey"), "wrong output (%s)\n",buffer);
277 r = MsiCloseHandle(hrec);
278 ok(r==ERROR_SUCCESS, "Unable to close record\n");
279 hrec = MsiCreateRecord(12);
280 ok( hrec, "failed to create record\n");
282 r = MsiRecordSetString(hrec, 0, "[[3][1]] [2]");
283 r = MsiRecordSetString(hrec, 1, "2");
284 r = MsiRecordSetString(hrec, 2, "hey");
285 r = MsiRecordSetString(hrec, 3, "1");
286 r = MsiRecordSetString(hrec, 12, "big");
287 ok( r == ERROR_SUCCESS, "set string failed\n");
289 r = MsiFormatRecord(0, hrec, buffer, &sz);
290 ok( r == ERROR_SUCCESS, "format failed\n");
291 ok( sz == 7, "size wrong,(%li)\n",sz);
292 ok( 0 == strcmp(buffer,"big hey"), "wrong output (%s)\n",buffer);
294 r = MsiRecordSetString(hrec, 0, "[[3][4][1]] [2]");
295 r = MsiRecordSetString(hrec, 1, "2");
296 r = MsiRecordSetString(hrec, 2, "hey");
297 r = MsiRecordSetString(hrec, 3, "1");
298 r = MsiRecordSetString(hrec, 4, NULL);
299 r = MsiRecordSetString(hrec, 12, "big");
300 ok( r == ERROR_SUCCESS, "set string failed\n");
302 r = MsiFormatRecord(0, hrec, buffer, &sz);
303 ok( r == ERROR_SUCCESS, "format failed\n");
304 ok( sz == 7, "size wrong,(%li)\n",sz);
305 ok( 0 == strcmp(buffer,"big hey"), "wrong output (%s)\n",buffer);
307 r = MsiRecordSetString(hrec, 0, "[[3][[4]][1]] [2]");
308 r = MsiRecordSetString(hrec, 1, "2");
309 r = MsiRecordSetString(hrec, 2, "hey");
310 r = MsiRecordSetString(hrec, 3, "1");
311 r = MsiRecordSetString(hrec, 4, NULL);
312 r = MsiRecordSetString(hrec, 12, "big");
313 ok( r == ERROR_SUCCESS, "set string failed\n");
315 r = MsiFormatRecord(0, hrec, buffer, &sz);
316 ok( r == ERROR_SUCCESS, "format failed\n");
317 ok( sz == 10, "size wrong,(%li)\n",sz);
318 ok( 0 == strcmp(buffer,"[1[]2] hey"), "wrong output (%s)\n",buffer);
320 /* incorrect formats */
321 r = MsiRecordSetString(hrec, 0, "[[[3][[4]][1]] [2]");
322 r = MsiRecordSetString(hrec, 1, "2");
323 r = MsiRecordSetString(hrec, 2, "hey");
324 r = MsiRecordSetString(hrec, 3, "1");
325 r = MsiRecordSetString(hrec, 4, NULL);
326 r = MsiRecordSetString(hrec, 12, "big");
327 ok( r == ERROR_SUCCESS, "set string failed\n");
329 r = MsiFormatRecord(0, hrec, buffer, &sz);
330 ok( r == ERROR_SUCCESS, "format failed\n");
331 ok( sz == 18, "size wrong,(%li)\n",sz);
332 ok( 0 == strcmp(buffer,"[[[3][[4]][1]] [2]"), "wrong output (%s)\n",buffer);
334 r = MsiRecordSetString(hrec, 0, "[[3][[4]][1]] [2]]");
335 r = MsiRecordSetString(hrec, 1, "2");
336 r = MsiRecordSetString(hrec, 2, "hey");
337 r = MsiRecordSetString(hrec, 3, "1");
338 r = MsiRecordSetString(hrec, 4, NULL);
339 r = MsiRecordSetString(hrec, 12, "big");
340 ok( r == ERROR_SUCCESS, "set string failed\n");
342 r = MsiFormatRecord(0, hrec, buffer, &sz);
343 ok( r == ERROR_SUCCESS, "format failed\n");
344 ok( sz == 11, "size wrong,(%li)\n",sz);
345 ok( 0 == strcmp(buffer,"[1[]2] hey]"), "wrong output (%s)\n",buffer);
348 /* play games with {} */
350 r = MsiRecordSetString(hrec, 0, "{[3][1]} [2]");
351 r = MsiRecordSetString(hrec, 1, "2");
352 r = MsiRecordSetString(hrec, 2, "hey");
353 r = MsiRecordSetString(hrec, 3, "1");
354 r = MsiRecordSetString(hrec, 4, NULL);
355 r = MsiRecordSetString(hrec, 12, "big");
356 ok( r == ERROR_SUCCESS, "set string failed\n");
358 r = MsiFormatRecord(0, hrec, buffer, &sz);
359 ok( r == ERROR_SUCCESS, "format failed\n");
360 ok( sz == 6, "size wrong,(%li)\n",sz);
361 ok( 0 == strcmp(buffer,"12 hey"), "wrong output (%s)\n",buffer);
363 r = MsiRecordSetString(hrec, 0, "[{[3][1]}] [2]");
364 r = MsiRecordSetString(hrec, 1, "2");
365 r = MsiRecordSetString(hrec, 2, "hey");
366 r = MsiRecordSetString(hrec, 3, "1");
367 r = MsiRecordSetString(hrec, 4, NULL);
368 r = MsiRecordSetString(hrec, 12, "big");
369 ok( r == ERROR_SUCCESS, "set string failed\n");
371 r = MsiFormatRecord(0, hrec, buffer, &sz);
372 ok( r == ERROR_SUCCESS, "format failed\n");
373 ok( sz == 8, "size wrong,(%li)\n",sz);
374 ok( 0 == strcmp(buffer,"[12] hey"), "wrong output (%s)\n",buffer);
377 r = MsiRecordSetString(hrec, 0, "{test} [2]");
378 r = MsiRecordSetString(hrec, 1, "2");
379 r = MsiRecordSetString(hrec, 2, "hey");
380 r = MsiRecordSetString(hrec, 3, "1");
381 r = MsiRecordSetString(hrec, 4, NULL);
382 r = MsiRecordSetString(hrec, 12, "big");
383 ok( r == ERROR_SUCCESS, "set string failed\n");
385 r = MsiFormatRecord(0, hrec, buffer, &sz);
386 ok( r == ERROR_SUCCESS, "format failed\n");
387 ok( sz == 10, "size wrong,(%li)\n",sz);
388 ok( 0 == strcmp(buffer,"{test} hey"), "wrong output (%s)\n",buffer);
390 r = MsiRecordSetString(hrec, 0, "{[test]} [2]");
391 r = MsiRecordSetString(hrec, 1, "2");
392 r = MsiRecordSetString(hrec, 2, "hey");
393 r = MsiRecordSetString(hrec, 3, "1");
394 r = MsiRecordSetString(hrec, 4, NULL);
395 r = MsiRecordSetString(hrec, 12, "big");
396 ok( r == ERROR_SUCCESS, "set string failed\n");
398 r = MsiFormatRecord(0, hrec, buffer, &sz);
399 ok( r == ERROR_SUCCESS, "format failed\n");
400 ok( sz == 12, "size wrong,(%li)\n",sz);
401 ok( 0 == strcmp(buffer,"{[test]} hey"), "wrong output (%s)\n",buffer);
403 r = MsiRecordSetString(hrec, 0, "{[1][2][3][4]} [2]");
404 r = MsiRecordSetString(hrec, 1, "2");
405 r = MsiRecordSetString(hrec, 2, "hey");
406 r = MsiRecordSetString(hrec, 3, "1");
407 r = MsiRecordSetString(hrec, 4, NULL);
408 r = MsiRecordSetString(hrec, 12, "big");
409 ok( r == ERROR_SUCCESS, "set string failed\n");
411 r = MsiFormatRecord(0, hrec, buffer, &sz);
412 ok( r == ERROR_SUCCESS, "format failed\n");
413 ok( sz == 4, "size wrong,(%li)\n",sz);
414 ok( 0 == strcmp(buffer," hey"), "wrong output (%s)\n",buffer);
416 r = MsiRecordSetString(hrec, 0, "{[1][2][3][dummy]} [2]");
417 r = MsiRecordSetString(hrec, 1, "2");
418 r = MsiRecordSetString(hrec, 2, "hey");
419 r = MsiRecordSetString(hrec, 3, "1");
420 r = MsiRecordSetString(hrec, 4, NULL);
421 r = MsiRecordSetString(hrec, 12, "big");
422 ok( r == ERROR_SUCCESS, "set string failed\n");
424 r = MsiFormatRecord(0, hrec, buffer, &sz);
425 ok( r == ERROR_SUCCESS, "format failed\n");
426 ok( sz == 18, "size wrong,(%li)\n",sz);
427 ok( 0 == strcmp(buffer,"{2hey1[dummy]} hey"), "wrong output (%s)\n",buffer);
429 r = MsiRecordSetString(hrec, 0, "{[1][2][3][4][dummy]} [2]");
430 r = MsiRecordSetString(hrec, 1, "2");
431 r = MsiRecordSetString(hrec, 2, "hey");
432 r = MsiRecordSetString(hrec, 3, "1");
433 r = MsiRecordSetString(hrec, 4, NULL);
434 r = MsiRecordSetString(hrec, 12, "big");
435 ok( r == ERROR_SUCCESS, "set string failed\n");
437 r = MsiFormatRecord(0, hrec, buffer, &sz);
438 ok( r == ERROR_SUCCESS, "format failed\n");
439 ok( sz == 18, "size wrong,(%li)\n",sz);
440 ok( 0 == strcmp(buffer,"{2hey1[dummy]} hey"), "wrong output (%s)\n",buffer);
442 r = MsiRecordSetString(hrec, 0, "{{[1][2]}[3][4][dummy]}");
443 r = MsiRecordSetString(hrec, 1, "2");
444 r = MsiRecordSetString(hrec, 2, "hey");
445 r = MsiRecordSetString(hrec, 3, "1");
446 r = MsiRecordSetString(hrec, 4, NULL);
447 r = MsiRecordSetString(hrec, 12, "big");
448 ok( r == ERROR_SUCCESS, "set string failed\n");
450 r = MsiFormatRecord(0, hrec, buffer, &sz);
451 ok( r == ERROR_SUCCESS, "format failed\n");
454 ok( sz == 16, "size wrong,(%li)\n",sz);
455 ok( 0 == strcmp(buffer,"{{2hey}1[dummy]}"), "wrong output (%s)\n",buffer);
458 r = MsiRecordSetString(hrec, 0, "{{[1][2]}[3]{[4][dummy]}}");
459 r = MsiRecordSetString(hrec, 1, "2");
460 r = MsiRecordSetString(hrec, 2, "hey");
461 r = MsiRecordSetString(hrec, 3, "1");
462 r = MsiRecordSetString(hrec, 4, NULL);
463 r = MsiRecordSetString(hrec, 12, "big");
464 ok( r == ERROR_SUCCESS, "set string failed\n");
466 r = MsiFormatRecord(0, hrec, buffer, &sz);
467 ok( r == ERROR_SUCCESS, "format failed\n");
469 ok( sz == 0, "size wrong,(%li)\n",sz);
470 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
473 r = MsiRecordSetString(hrec, 0, "{{[1][2]}[3]} {[1][2]}");
474 r = MsiRecordSetString(hrec, 1, "1");
475 r = MsiRecordSetString(hrec, 2, "2");
476 r = MsiRecordSetString(hrec, 3, "3");
477 r = MsiRecordSetString(hrec, 4, NULL);
478 r = MsiRecordSetString(hrec, 12, "big");
479 ok( r == ERROR_SUCCESS, "set string failed\n");
481 r = MsiFormatRecord(0, hrec, buffer, &sz);
482 ok( r == ERROR_SUCCESS, "format failed\n");
484 ok( sz == 12, "size wrong,(%li)\n",sz);
485 ok( 0 == strcmp(buffer,"{{12}3} {12}"), "wrong output (%s)\n",buffer);
488 r = MsiRecordSetString(hrec, 0, "{[1][2]} {{[1][2]}[3]} {[1][2]}");
489 r = MsiRecordSetString(hrec, 1, "1");
490 r = MsiRecordSetString(hrec, 2, "2");
491 r = MsiRecordSetString(hrec, 3, "3");
492 r = MsiRecordSetString(hrec, 4, NULL);
493 r = MsiRecordSetString(hrec, 12, "big");
494 ok( r == ERROR_SUCCESS, "set string failed\n");
496 r = MsiFormatRecord(0, hrec, buffer, &sz);
497 ok( r == ERROR_SUCCESS, "format failed\n");
499 ok( sz == 15, "size wrong,(%li)\n",sz);
500 ok( 0 == strcmp(buffer,"12 {{12}3} {12}"), "wrong output (%s)\n",buffer);
503 r = MsiRecordSetString(hrec, 0, "{[4]}{[1][2]} {{[1][2]}[3]} {[1][2]}");
504 r = MsiRecordSetString(hrec, 1, "1");
505 r = MsiRecordSetString(hrec, 2, "2");
506 r = MsiRecordSetString(hrec, 3, "3");
507 r = MsiRecordSetString(hrec, 4, NULL);
508 r = MsiRecordSetString(hrec, 12, "big");
509 ok( r == ERROR_SUCCESS, "set string failed\n");
511 r = MsiFormatRecord(0, hrec, buffer, &sz);
512 ok( r == ERROR_SUCCESS, "format failed\n");
514 ok( sz == 15, "size wrong,(%li)\n",sz);
515 ok( 0 == strcmp(buffer,"12 {{12}3} {12}"), "wrong output (%s)\n",buffer);
519 r = MsiRecordSetString(hrec, 0, "{blah} {[4]}{[1][2]} {{[1][2]}[3]} {[1][2]}");
520 r = MsiRecordSetString(hrec, 1, "1");
521 r = MsiRecordSetString(hrec, 2, "2");
522 r = MsiRecordSetString(hrec, 3, "3");
523 r = MsiRecordSetString(hrec, 4, NULL);
524 r = MsiRecordSetString(hrec, 12, "big");
525 ok( r == ERROR_SUCCESS, "set string failed\n");
527 r = MsiFormatRecord(0, hrec, buffer, &sz);
528 ok( r == ERROR_SUCCESS, "format failed\n");
530 ok( sz == 22, "size wrong,(%li)\n",sz);
531 ok( 0 == strcmp(buffer,"{blah} 12 {{12}3} {12}"), "wrong output (%s)\n",buffer);
534 r = MsiRecordSetString(hrec, 0, "{{[1]}[2]} {[4]}{[1][2]}");
535 r = MsiRecordSetString(hrec, 1, "1");
536 r = MsiRecordSetString(hrec, 2, "2");
537 r = MsiRecordSetString(hrec, 3, "3");
538 r = MsiRecordSetString(hrec, 4, NULL);
539 r = MsiRecordSetString(hrec, 12, "big");
540 ok( r == ERROR_SUCCESS, "set string failed\n");
542 r = MsiFormatRecord(0, hrec, buffer, &sz);
543 ok( r == ERROR_SUCCESS, "format failed\n");
545 ok( sz == 13, "size wrong,(%li)\n",sz);
546 ok( 0 == strcmp(buffer,"{{1}2} {}{12}"), "wrong output (%s)\n",buffer);
549 r = MsiRecordSetString(hrec, 0, "{{[1]}} {[4]}{[1][2]}");
550 r = MsiRecordSetString(hrec, 1, "1");
551 r = MsiRecordSetString(hrec, 2, "2");
552 r = MsiRecordSetString(hrec, 3, "3");
553 r = MsiRecordSetString(hrec, 4, NULL);
554 r = MsiRecordSetString(hrec, 12, "big");
555 ok( r == ERROR_SUCCESS, "set string failed\n");
557 r = MsiFormatRecord(0, hrec, buffer, &sz);
558 ok( r == ERROR_SUCCESS, "format failed\n");
560 ok( sz == 3, "size wrong,(%li)\n",sz);
561 ok( 0 == strcmp(buffer," 12"), "wrong output (%s)\n",buffer);
564 r = MsiRecordSetString(hrec, 0, "{{{[1]}} {[4]}{[1][2]}");
565 r = MsiRecordSetString(hrec, 1, "1");
566 r = MsiRecordSetString(hrec, 2, "2");
567 r = MsiRecordSetString(hrec, 3, "3");
568 r = MsiRecordSetString(hrec, 4, NULL);
569 r = MsiRecordSetString(hrec, 12, "big");
570 ok( r == ERROR_SUCCESS, "set string failed\n");
572 r = MsiFormatRecord(0, hrec, buffer, &sz);
573 ok( r == ERROR_SUCCESS, "format failed\n");
575 ok( sz == 3, "size wrong,(%li)\n",sz);
576 ok( 0 == strcmp(buffer," 12"), "wrong output (%s)\n",buffer);
579 /* now put play games with escaping */
580 r = MsiRecordSetString(hrec, 0, "[1] [2] [\\3asdf]");
581 r = MsiRecordSetString(hrec, 1, "boo");
582 r = MsiRecordSetString(hrec, 2, "hoo");
583 ok( r == ERROR_SUCCESS, "set string failed\n");
585 r = MsiFormatRecord(0, hrec, buffer, &sz);
586 ok( r == ERROR_SUCCESS, "format failed\n");
587 ok( sz == 16, "size wrong\n");
588 ok( 0 == strcmp(buffer,"boo hoo [\\3asdf]"), "wrong output\n");
590 /* now put play games with escaping */
591 r = MsiRecordSetString(hrec, 0, "[1] [2] [\\x]");
592 r = MsiRecordSetString(hrec, 1, "boo");
593 r = MsiRecordSetString(hrec, 2, "hoo");
594 ok( r == ERROR_SUCCESS, "set string failed\n");
596 r = MsiFormatRecord(0, hrec, buffer, &sz);
597 ok( r == ERROR_SUCCESS, "format failed\n");
598 ok( sz == 12, "size wrong\n");
599 ok( 0 == strcmp(buffer,"boo hoo [\\x]"), "wrong output\n");
601 /* now try other formats without a package */
602 r = MsiRecordSetString(hrec, 0, "[1] [2] [property]");
603 r = MsiRecordSetString(hrec, 1, "boo");
604 r = MsiRecordSetString(hrec, 2, "hoo");
605 ok( r == ERROR_SUCCESS, "set string failed\n");
607 r = MsiFormatRecord(0, hrec, buffer, &sz);
608 ok( r == ERROR_SUCCESS, "format failed\n");
609 ok( sz == 18, "size wrong\n");
610 ok( 0 == strcmp(buffer,"boo hoo [property]"), "wrong output\n");
612 r = MsiRecordSetString(hrec, 0, "[1] [~] [2]");
613 r = MsiRecordSetString(hrec, 1, "boo");
614 r = MsiRecordSetString(hrec, 2, "hoo");
615 ok( r == ERROR_SUCCESS, "set string failed\n");
617 r = MsiFormatRecord(0, hrec, buffer, &sz);
618 ok( r == ERROR_SUCCESS, "format failed\n");
619 ok( sz == 11, "size wrong\n");
620 ok( 0 == strcmp(buffer,"boo [~] hoo"), "wrong output (%s)\n",buffer);
622 r = MsiRecordSetString(hrec, 0, "[1]");
623 r = MsiRecordSetInteger(hrec, 1, 123456);
624 ok( r == ERROR_SUCCESS, "set integer failed\n");
626 r = MsiFormatRecord(0, hrec, buffer, &sz);
627 ok( r == ERROR_SUCCESS, "format failed\n");
629 ok( sz == 6, "size wrong\n");
630 ok( 0 == strcmp(buffer,"123456"), "wrong output (%s)\n",buffer);
633 r = MsiRecordSetString(hrec, 0, "[~]");
635 r = MsiFormatRecord(0, hrec, buffer, &sz);
636 ok( sz == 3, "size wrong\n");
637 ok( 0 == strcmp(buffer,"[~]"), "wrong output\n");
638 ok( r == ERROR_SUCCESS, "format failed\n");
640 r = MsiRecordSetString(hrec, 0, "[]");
642 r = MsiFormatRecord(0, hrec, buffer, &sz);
643 ok( sz == 2, "size wrong\n");
644 ok( 0 == strcmp(buffer,"[]"), "wrong output\n");
645 ok( r == ERROR_SUCCESS, "format failed\n");
647 /* MsiFormatRecord doesn't seem to handle a negative too well */
648 r = MsiRecordSetString(hrec, 0, "[-1]");
650 r = MsiFormatRecord(0, hrec, buffer, &sz);
651 ok( sz == 4, "size wrong\n");
652 ok( 0 == strcmp(buffer,"[-1]"), "wrong output\n");
653 ok( r == ERROR_SUCCESS, "format failed\n");
655 r = MsiRecordSetString(hrec, 0, "{[]}");
657 r = MsiFormatRecord(0, hrec, buffer, &sz);
658 ok( sz == 4, "size wrong\n");
659 ok( 0 == strcmp(buffer,"{[]}"), "wrong output\n");
660 ok( r == ERROR_SUCCESS, "format failed\n");
662 r = MsiRecordSetString(hrec, 0, "[0]");
664 r = MsiFormatRecord(0, hrec, buffer, &sz);
665 ok( sz == 3, "size wrong\n");
666 ok( 0 == strcmp(buffer,"[0]"), "wrong output\n");
667 ok( r == ERROR_SUCCESS, "format failed\n");
669 r = MsiRecordSetString(hrec, 0, "[100]");
671 r = MsiFormatRecord(0, hrec, buffer, &sz);
672 ok( sz == 0, "size wrong\n");
673 ok( 0 == strcmp(buffer,""), "wrong output\n");
674 ok( r == ERROR_SUCCESS, "format failed\n");
676 r = MsiRecordSetString(hrec, 0, "{[1] [2]}");
677 r = MsiRecordSetString(hrec, 1, "boo");
678 r = MsiRecordSetString(hrec, 2, "hoo");
680 r = MsiFormatRecord(0, hrec, buffer, &sz);
681 ok( sz == 7, "size wrong\n");
682 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
683 ok( r == ERROR_SUCCESS, "format failed\n");
685 r = MsiRecordSetString(hrec, 0, "{}");
687 r = MsiFormatRecord(0, hrec, buffer, &sz);
688 ok( sz == 0, "size wrong\n");
689 ok( 0 == strcmp(buffer,""), "wrong output\n");
690 ok( r == ERROR_SUCCESS, "format failed\n");
692 r = MsiRecordSetString(hrec, 0, "{foo}");
694 r = MsiFormatRecord(0, hrec, buffer, &sz);
695 ok( sz == 5, "size wrong\n");
696 ok( 0 == strcmp(buffer,"{foo}"), "wrong output\n");
697 ok( r == ERROR_SUCCESS, "format failed\n");
699 r = MsiRecordSetString(hrec, 0, "{boo [1]}");
700 r = MsiRecordSetString(hrec, 1, "hoo");
702 r = MsiFormatRecord(0, hrec, buffer, &sz);
703 ok( sz == 7, "size wrong\n");
704 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
705 ok( r == ERROR_SUCCESS, "format failed\n");
708 r = MsiRecordSetString(hrec, 0, "{{[1]}}");
709 r = MsiRecordSetString(hrec, 1, "hoo");
711 r = MsiFormatRecord(0, hrec, buffer, &sz);
712 ok( sz == 0, "size wrong\n");
713 ok( 0 == strcmp(buffer,""), "wrong output\n");
715 ok( r == ERROR_SUCCESS, "format failed\n");
717 r = MsiRecordSetString(hrec, 0, "{ {[1]}}");
718 r = MsiRecordSetString(hrec, 1, "hoo");
720 r = MsiFormatRecord(0, hrec, buffer, &sz);
721 ok( 0 == strcmp(buffer," {hoo}"), "wrong output\n");
722 ok( sz == 6, "size wrong\n");
723 ok( r == ERROR_SUCCESS, "format failed\n");
726 r = MsiRecordSetString(hrec, 0, "{{[1]} }");
727 r = MsiRecordSetString(hrec, 1, "hoo");
729 r = MsiFormatRecord(0, hrec, buffer, &sz);
730 ok( sz == 8, "size wrong\n");
731 ok( 0 == strcmp(buffer,"{{hoo} }"), "wrong output\n");
733 ok( r == ERROR_SUCCESS, "format failed\n");
736 r = MsiRecordSetString(hrec, 0, "{{ [1]}}");
737 r = MsiRecordSetString(hrec, 1, "hoo");
739 r = MsiFormatRecord(0, hrec, buffer, &sz);
740 ok( sz == 0, "size wrong\n");
741 ok( 0 == strcmp(buffer,""), "wrong output\n");
743 ok( r == ERROR_SUCCESS, "format failed\n");
746 r = MsiRecordSetString(hrec, 0, "{{[1] }}");
747 r = MsiRecordSetString(hrec, 1, "hoo");
749 r = MsiFormatRecord(0, hrec, buffer, &sz);
750 ok( sz == 0, "size wrong\n");
751 ok( 0 == strcmp(buffer,""), "wrong output\n");
753 ok( r == ERROR_SUCCESS, "format failed\n");
756 r = MsiRecordSetString(hrec, 0, "{{a}{b}{c }{ d}{any text}}");
758 r = MsiFormatRecord(0, hrec, buffer, &sz);
759 ok( sz == 0, "size wrong\n");
760 ok( 0 == strcmp(buffer,""), "wrong output\n");
762 ok( r == ERROR_SUCCESS, "format failed\n");
764 r = MsiRecordSetString(hrec, 0, "{{a} }");
766 r = MsiFormatRecord(0, hrec, buffer, &sz);
767 ok( sz == 6, "size wrong\n");
768 ok( 0 == strcmp(buffer,"{{a} }"), "wrong output\n");
769 ok( r == ERROR_SUCCESS, "format failed\n");
772 r = MsiRecordSetString(hrec, 0, "{{a} {b}}");
774 r = MsiFormatRecord(0, hrec, buffer, &sz);
775 ok( sz == 0, "size wrong\n");
776 ok( 0 == strcmp(buffer,""), "wrong output\n");
778 ok( r == ERROR_SUCCESS, "format failed\n");
781 r = MsiRecordSetString(hrec, 0, "{{a} b}}");
783 r = MsiFormatRecord(0, hrec, buffer, &sz);
784 ok( sz == 0, "size wrong\n");
785 ok( 0 == strcmp(buffer,""), "wrong output\n");
787 ok( r == ERROR_SUCCESS, "format failed\n");
790 r = MsiRecordSetString(hrec, 0, "{{a b}}");
792 r = MsiFormatRecord(0, hrec, buffer, &sz);
793 ok( sz == 0, "size wrong\n");
794 ok( 0 == strcmp(buffer,""), "wrong output\n");
796 ok( r == ERROR_SUCCESS, "format failed\n");
798 r = MsiRecordSetString(hrec, 0, "{ }");
800 r = MsiFormatRecord(0, hrec, buffer, &sz);
801 ok( sz == 3, "size wrong\n");
802 ok( 0 == strcmp(buffer,"{ }"), "wrong output\n");
803 ok( r == ERROR_SUCCESS, "format failed\n");
806 r = MsiRecordSetString(hrec, 0, " {{a}}}");
808 r = MsiFormatRecord(0, hrec, buffer, &sz);
809 ok( sz == 2, "size wrong\n");
810 ok( 0 == strcmp(buffer," }"), "wrong output\n");
812 ok( r == ERROR_SUCCESS, "format failed\n");
815 r = MsiRecordSetString(hrec, 0, "{{ almost {{ any }} text }}");
817 r = MsiFormatRecord(0, hrec, buffer, &sz);
818 ok( sz == 8, "size wrong\n");
819 ok( 0 == strcmp(buffer," text }}"), "wrong output\n");
821 ok( r == ERROR_SUCCESS, "format failed\n");
824 r = MsiRecordSetString(hrec, 0, "{{ } { hidden ][ [ }}");
826 r = MsiFormatRecord(0, hrec, buffer, &sz);
827 ok( sz == 0, "size wrong\n");
828 ok( 0 == strcmp(buffer,""), "wrong output\n");
830 ok( r == ERROR_SUCCESS, "format failed\n");
832 r = MsiRecordSetString(hrec, 0, "[ 1]");
833 r = MsiRecordSetString(hrec, 1, "hoo");
835 r = MsiFormatRecord(0, hrec, buffer, &sz);
836 ok( sz == 4, "size wrong\n");
837 ok( 0 == strcmp(buffer,"[ 1]"), "wrong output\n");
838 ok( r == ERROR_SUCCESS, "format failed\n");
840 r = MsiRecordSetString(hrec, 0, "[01]");
841 r = MsiRecordSetString(hrec, 1, "hoo");
843 r = MsiFormatRecord(0, hrec, buffer, &sz);
844 ok( sz == 3, "size wrong\n");
845 ok( 0 == strcmp(buffer,"hoo"), "wrong output\n");
846 ok( r == ERROR_SUCCESS, "format failed\n");
849 r = MsiRecordSetString(hrec, 0, "{{test}} [01");
850 r = MsiRecordSetString(hrec, 1, "hoo");
852 r = MsiFormatRecord(0, hrec, buffer, &sz);
853 ok( sz == 4, "size wrong\n");
854 ok( 0 == strcmp(buffer," [01"), "wrong output\n");
856 ok( r == ERROR_SUCCESS, "format failed\n");
858 r = MsiRecordSetString(hrec, 0, "[\\[]");
859 r = MsiRecordSetString(hrec, 1, "hoo");
861 r = MsiFormatRecord(0, hrec, buffer, &sz);
862 ok( sz == 4, "size wrong\n");
863 ok( 0 == strcmp(buffer,"[\\[]"), "wrong output\n");
864 ok( r == ERROR_SUCCESS, "format failed\n");
866 r = MsiRecordSetString(hrec, 0, "[foo]");
867 r = MsiRecordSetString(hrec, 1, "hoo");
869 r = MsiFormatRecord(0, hrec, buffer, &sz);
870 ok( sz == 5, "size wrong\n");
871 ok( 0 == strcmp(buffer,"[foo]"), "wrong output\n");
872 ok( r == ERROR_SUCCESS, "format failed\n");
874 r = MsiRecordSetString(hrec, 0, "[01.]");
875 r = MsiRecordSetString(hrec, 1, "hoo");
877 r = MsiFormatRecord(0, hrec, buffer, &sz);
878 ok( sz == 5, "size wrong\n");
879 ok( 0 == strcmp(buffer,"[01.]"), "wrong output\n");
880 ok( r == ERROR_SUCCESS, "format failed\n");
882 SetEnvironmentVariable("FOO", "BAR");
883 r = MsiRecordSetString(hrec, 0, "[%FOO]");
885 r = MsiFormatRecord(0, hrec, buffer, &sz);
886 ok( sz == 6, "size wrong\n");
887 ok( 0 == strcmp(buffer,"[%FOO]"), "wrong output\n");
888 ok( r == ERROR_SUCCESS, "format failed\n");
891 r = MsiRecordSetString(hrec, 0, "{{[1]}");
892 r = MsiRecordSetString(hrec, 1, "hoo");
894 r = MsiFormatRecord(0, hrec, buffer, &sz);
895 ok( sz == 6, "size wrong\n");
896 ok( 0 == strcmp(buffer,"{{hoo}"), "wrong output\n");
898 ok( r == ERROR_SUCCESS, "format failed\n");
901 r = MsiRecordSetString(hrec, 0, "{{ {[1]}");
902 r = MsiRecordSetString(hrec, 1, "hoo");
904 r = MsiFormatRecord(0, hrec, buffer, &sz);
905 ok( sz == 8, "size wrong\n");
906 ok( 0 == strcmp(buffer,"{{ {hoo}"), "wrong output\n");
908 ok( r == ERROR_SUCCESS, "format failed\n");
911 r = MsiRecordSetString(hrec, 0, "{{ {[1]}");
912 r = MsiRecordSetString(hrec, 1, "hoo");
914 r = MsiFormatRecord(0, hrec, buffer, &sz);
915 ok( sz == 8, "size wrong\n");
916 ok( 0 == strcmp(buffer,"{{ {hoo}"), "wrong output\n");
918 ok( r == ERROR_SUCCESS, "format failed\n");
921 r = MsiRecordSetString(hrec, 0, "{{ {{[1]}");
922 r = MsiRecordSetString(hrec, 1, "hoo");
924 r = MsiFormatRecord(0, hrec, buffer, &sz);
925 ok( sz == 9, "size wrong\n");
926 ok( 0 == strcmp(buffer,"{{ {{hoo}"), "wrong output\n");
928 ok( r == ERROR_SUCCESS, "format failed\n");
930 r = MsiRecordSetString(hrec, 0, "[1]}");
931 r = MsiRecordSetString(hrec, 1, "hoo");
933 r = MsiFormatRecord(0, hrec, buffer, &sz);
934 ok( sz == 4, "size wrong\n");
935 ok( 0 == strcmp(buffer,"hoo}"), "wrong output\n");
936 ok( r == ERROR_SUCCESS, "format failed\n");
938 r = MsiRecordSetString(hrec, 0, "{{ {{a}");
940 r = MsiFormatRecord(0, hrec, buffer, &sz);
941 ok( sz == 7, "size wrong\n");
942 ok( 0 == strcmp(buffer,"{{ {{a}"), "wrong output\n");
943 ok( r == ERROR_SUCCESS, "format failed\n");
945 r = MsiRecordSetString(hrec, 0, "{{ {{a}");
947 r = MsiFormatRecord(0, hrec, buffer, &sz);
948 ok( sz == 7, "size wrong\n");
949 ok( 0 == strcmp(buffer,"{{ {{a}"), "wrong output\n");
950 ok( r == ERROR_SUCCESS, "format failed\n");
952 r = MsiRecordSetString(hrec, 0, "0{1{2{3{4[1]5}6}7}8}9");
953 r = MsiRecordSetString(hrec, 1, "hoo");
955 r = MsiFormatRecord(0, hrec, buffer, &sz);
956 ok( sz == 19, "size wrong\n");
957 ok( 0 == strcmp(buffer,"01{2{3{4hoo56}7}8}9"), "wrong output\n");
958 ok( r == ERROR_SUCCESS, "format failed\n");
960 r = MsiRecordSetString(hrec, 0, "0{1{2[1]3}4");
961 r = MsiRecordSetString(hrec, 1, "hoo");
963 r = MsiFormatRecord(0, hrec, buffer, &sz);
964 ok( sz == 9, "size wrong\n");
965 ok( 0 == strcmp(buffer,"01{2hoo34"), "wrong output\n");
966 ok( r == ERROR_SUCCESS, "format failed\n");
968 r = MsiRecordSetString(hrec, 0, "0{1{2[1]3}4");
969 r = MsiRecordSetString(hrec, 1, "hoo");
971 r = MsiFormatRecord(0, hrec, buffer, &sz);
972 ok( sz == 9, "size wrong\n");
973 ok( 0 == strcmp(buffer,"01{2hoo34"), "wrong output\n");
974 ok( r == ERROR_SUCCESS, "format failed\n");
976 r = MsiRecordSetString(hrec, 0, "{[1.} [1]");
977 r = MsiRecordSetString(hrec, 1, "hoo");
979 r = MsiFormatRecord(0, hrec, buffer, &sz);
980 ok( sz == 9, "size wrong\n");
981 ok( 0 == strcmp(buffer,"{[1.} hoo"), "wrong output\n");
982 ok( r == ERROR_SUCCESS, "format failed\n");
984 r = MsiRecordSetString(hrec, 0, "{[{[1]}]}");
985 r = MsiRecordSetString(hrec, 1, "2");
986 r = MsiRecordSetString(hrec, 2, "foo");
988 r = MsiFormatRecord(0, hrec, buffer, &sz);
989 ok( sz == 9, "size wrong\n");
990 ok( 0 == strcmp(buffer,"{[{[1]}]}"), "wrong output\n");
991 ok( r == ERROR_SUCCESS, "format failed\n");
993 r = MsiRecordSetString(hrec, 0, "{[1][}");
994 r = MsiRecordSetString(hrec, 1, "2");
995 r = MsiRecordSetString(hrec, 2, "foo");
997 r = MsiFormatRecord(0, hrec, buffer, &sz);
998 ok( sz == 2, "size wrong\n");
999 ok( 0 == strcmp(buffer,"2["), "wrong output\n");
1000 ok( r == ERROR_SUCCESS, "format failed\n");
1002 r = MsiRecordSetString(hrec, 0, "[1]");
1003 r = MsiRecordSetString(hrec, 1, "[2]");
1004 r = MsiRecordSetString(hrec, 2, "foo");
1006 r = MsiFormatRecord(0, hrec, buffer, &sz);
1007 ok( sz == 3, "size wrong\n");
1008 ok( 0 == strcmp(buffer,"[2]"), "wrong output\n");
1009 ok( r == ERROR_SUCCESS, "format failed\n");
1012 r = MsiRecordSetString(hrec, 0, "[{{boo}}1]");
1013 r = MsiRecordSetString(hrec, 1, "hoo");
1015 r = MsiFormatRecord(0, hrec, buffer, &sz);
1016 ok( sz == 3, "size wrong\n");
1017 ok( 0 == strcmp(buffer,"[1]"), "wrong output\n");
1019 ok( r == ERROR_SUCCESS, "format failed\n");
1022 r = MsiRecordSetString(hrec, 0, "[{{boo}}1]");
1023 r = MsiRecordSetString(hrec, 0, "[1{{boo}}]");
1024 r = MsiRecordSetString(hrec, 1, "hoo");
1026 r = MsiFormatRecord(0, hrec, buffer, &sz);
1027 ok( sz == 3, "size wrong\n");
1028 ok( 0 == strcmp(buffer,"[1]"), "wrong output\n");
1030 ok( r == ERROR_SUCCESS, "format failed\n");
1032 r = MsiRecordSetString(hrec, 0, "{[1]{{boo} }}");
1033 r = MsiRecordSetString(hrec, 1, "hoo");
1035 r = MsiFormatRecord(0, hrec, buffer, &sz);
1036 ok( sz == 11, "size wrong\n");
1037 ok( 0 == strcmp(buffer,"hoo{{boo }}"), "wrong output\n");
1038 ok( r == ERROR_SUCCESS, "format failed\n");
1040 r = MsiRecordSetString(hrec, 0, "{[1{{boo}}]}");
1041 r = MsiRecordSetString(hrec, 1, "hoo");
1043 r = MsiFormatRecord(0, hrec, buffer, &sz);
1044 ok( sz == 12, "size wrong: got %lu, expected 12\n", sz);
1045 ok( 0 == strcmp(buffer,"{[1{{boo}}]}"), "wrong output: got %s, expected [1]\n", buffer);
1046 ok( r == ERROR_SUCCESS, "format failed\n");
1049 r = MsiRecordSetString(hrec, 0, "{{[1]}");
1050 r = MsiRecordSetString(hrec, 1, "hoo");
1052 r = MsiFormatRecord(0, hrec, buffer, &sz);
1053 ok( sz == 6, "size wrong: got %lu, expected 3\n", sz);
1054 ok( 0 == strcmp(buffer,"{{hoo}"), "wrong output: got %s, expected [1]\n", buffer);
1056 ok( r == ERROR_SUCCESS, "format failed\n");
1058 r = MsiRecordSetString(hrec, 0, "{[1{{bo}o}}]}");
1059 r = MsiRecordSetString(hrec, 1, "hoo");
1061 r = MsiFormatRecord(0, hrec, buffer, &sz);
1062 ok( sz == 13, "size wrong\n");
1063 ok( 0 == strcmp(buffer,"{[1{{bo}o}}]}"), "wrong output %s\n",buffer);
1064 ok( r == ERROR_SUCCESS, "format failed\n");
1066 r = MsiRecordSetString(hrec, 0, "{[1{{b{o}o}}]}");
1068 r = MsiFormatRecord(0, hrec, buffer, &sz);
1069 ok( sz == 14, "size wrong\n");
1070 ok( 0 == strcmp(buffer,"{[1{{b{o}o}}]}"), "wrong output %s\n",buffer);
1071 ok( r == ERROR_SUCCESS, "format failed\n");
1073 r = MsiRecordSetString(hrec, 0, "{ {[1]}");
1074 r = MsiRecordSetString(hrec, 1, "hoo");
1076 r = MsiFormatRecord(0, hrec, buffer, &sz);
1077 ok( sz == 5, "size wrong\n");
1078 ok( 0 == strcmp(buffer," {hoo"), "wrong output %s\n",buffer);
1079 ok( r == ERROR_SUCCESS, "format failed\n");
1081 /* {} inside a substitution does strange things... */
1082 r = MsiRecordSetString(hrec, 0, "[[1]{}]");
1083 r = MsiRecordSetString(hrec, 1, "2");
1085 r = MsiFormatRecord(0, hrec, buffer, &sz);
1086 ok( sz == 5, "size wrong\n");
1087 ok( 0 == strcmp(buffer,"[[1]]"), "wrong output %s\n",buffer);
1088 ok( r == ERROR_SUCCESS, "format failed\n");
1090 r = MsiRecordSetString(hrec, 0, "[[1]{}[1]]");
1091 r = MsiRecordSetString(hrec, 1, "2");
1093 r = MsiFormatRecord(0, hrec, buffer, &sz);
1094 ok( sz == 6, "size wrong\n");
1095 ok( 0 == strcmp(buffer,"[[1]2]"), "wrong output %s\n",buffer);
1096 ok( r == ERROR_SUCCESS, "format failed\n");
1098 r = MsiRecordSetString(hrec, 0, "[a[1]b[1]c{}d[1]e]");
1099 r = MsiRecordSetString(hrec, 1, "2");
1101 r = MsiFormatRecord(0, hrec, buffer, &sz);
1102 ok( sz == 14, "size wrong\n");
1103 ok( 0 == strcmp(buffer,"[a[1]b[1]cd2e]"), "wrong output %s\n",buffer);
1104 ok( r == ERROR_SUCCESS, "format failed\n");
1106 r = MsiRecordSetString(hrec, 0, "[a[1]b");
1107 r = MsiRecordSetString(hrec, 1, "2");
1109 r = MsiFormatRecord(0, hrec, buffer, &sz);
1110 ok( sz == 6, "size wrong\n");
1111 ok( 0 == strcmp(buffer,"[a[1]b"), "wrong output %s\n",buffer);
1112 ok( r == ERROR_SUCCESS, "format failed\n");
1114 r = MsiRecordSetString(hrec, 0, "a[1]b]");
1115 r = MsiRecordSetString(hrec, 1, "2");
1117 r = MsiFormatRecord(0, hrec, buffer, &sz);
1118 ok( sz == 4, "size wrong\n");
1119 ok( 0 == strcmp(buffer,"a2b]"), "wrong output %s\n",buffer);
1120 ok( r == ERROR_SUCCESS, "format failed\n");
1122 r = MsiRecordSetString(hrec, 0, "]a[1]b");
1123 r = MsiRecordSetString(hrec, 1, "2");
1125 r = MsiFormatRecord(0, hrec, buffer, &sz);
1126 ok( sz == 4, "size wrong\n");
1127 ok( 0 == strcmp(buffer,"]a2b"), "wrong output %s\n",buffer);
1128 ok( r == ERROR_SUCCESS, "format failed\n");
1130 r = MsiRecordSetString(hrec, 0, "]a[1]b");
1131 r = MsiRecordSetString(hrec, 1, "2");
1133 r = MsiFormatRecord(0, hrec, buffer, &sz);
1134 ok( sz == 4, "size wrong\n");
1135 ok( 0 == strcmp(buffer,"]a2b"), "wrong output %s\n",buffer);
1136 ok( r == ERROR_SUCCESS, "format failed\n");
1138 r = MsiRecordSetString(hrec, 0, "\\[1]");
1139 r = MsiRecordSetString(hrec, 1, "2");
1141 r = MsiFormatRecord(0, hrec, buffer, &sz);
1142 ok( sz == 2, "size wrong\n");
1143 ok( 0 == strcmp(buffer,"\\2"), "wrong output %s\n",buffer);
1144 ok( r == ERROR_SUCCESS, "format failed\n");
1146 r = MsiRecordSetString(hrec, 0, "\\{[1]}");
1147 r = MsiRecordSetString(hrec, 1, "2");
1149 r = MsiFormatRecord(0, hrec, buffer, &sz);
1150 ok( sz == 2, "size wrong\n");
1151 ok( 0 == strcmp(buffer,"\\2"), "wrong output %s\n",buffer);
1152 ok( r == ERROR_SUCCESS, "format failed\n");
1154 r = MsiRecordSetString(hrec, 0, "a{b[1]c}d");
1155 r = MsiRecordSetString(hrec, 1, NULL);
1157 r = MsiFormatRecord(0, hrec, buffer, &sz);
1158 ok( sz == 2, "size wrong\n");
1159 ok( 0 == strcmp(buffer,"ad"), "wrong output %s\n",buffer);
1160 ok( r == ERROR_SUCCESS, "format failed\n");
1162 r = MsiRecordSetString(hrec, 0, "{a[0]b}");
1163 r = MsiRecordSetString(hrec, 1, "foo");
1165 r = MsiFormatRecord(0, hrec, buffer, &sz);
1166 ok( sz == 9, "size wrong\n");
1167 ok( 0 == strcmp(buffer,"a{a[0]b}b"), "wrong output %s\n",buffer);
1168 ok( r == ERROR_SUCCESS, "format failed\n");
1170 r = MsiRecordSetString(hrec, 0, "[foo]");
1172 r = MsiFormatRecord(0, hrec, buffer, &sz);
1173 ok( sz == 5, "size wrong\n");
1174 ok( 0 == strcmp(buffer,"[foo]"), "wrong output %s\n",buffer);
1175 ok( r == ERROR_SUCCESS, "format failed\n");
1177 r = MsiRecordSetString(hrec, 0, "{[1][-1][1]}");
1178 r = MsiRecordSetString(hrec, 1, "foo");
1180 r = MsiFormatRecord(0, hrec, buffer, &sz);
1181 ok( sz == 12, "size wrong\n");
1182 ok( 0 == strcmp(buffer,"{foo[-1]foo}"), "wrong output %s\n",buffer);
1183 ok( r == ERROR_SUCCESS, "format failed\n");
1186 static void test_formatrecord_package(void)
1188 static const CHAR filename[] = "winetest.msi";
1195 package = helper_createpackage( filename );
1196 ok(package!=0, "Unable to create package\n");
1198 hrec = MsiCreateRecord(12);
1199 ok( hrec, "failed to create record\n");
1201 r = MsiFormatRecord(package, 0, NULL, NULL );
1202 ok( r == ERROR_INVALID_HANDLE, "wrong error\n");
1204 r = MsiFormatRecord(package, hrec, NULL, NULL );
1205 ok( r == ERROR_SUCCESS, "format failed\n");
1207 r = MsiRecordSetString(hrec,0,NULL);
1208 r = MsiRecordSetString(hrec,1,NULL);
1209 r = MsiRecordSetString(hrec,2,NULL);
1210 r = MsiRecordSetString(hrec,3,NULL);
1211 r = MsiRecordSetString(hrec,4,NULL);
1212 r = MsiRecordSetString(hrec,5,NULL);
1213 r = MsiRecordSetString(hrec,6,NULL);
1214 r = MsiRecordSetString(hrec,7,NULL);
1215 r = MsiRecordSetString(hrec,8,NULL);
1216 r = MsiRecordSetString(hrec,9,NULL);
1217 r = MsiRecordSetString(hrec,10,NULL);
1218 r = MsiRecordSetString(hrec,11,NULL);
1219 r = MsiRecordSetString(hrec,12,NULL);
1220 ok( r == ERROR_SUCCESS, "set string failed\n");
1223 r = MsiFormatRecord(package, hrec, buffer, &sz);
1224 ok( r == ERROR_SUCCESS, "format failed with empty buffer (%i)\n",r);
1225 ok( sz == 51, "size wrong (%li)\n",sz);
1226 ok( 0 == strcmp(buffer,"1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: "), "wrong output(%s)\n",buffer);
1228 /* now put play games with escaping */
1229 r = MsiRecordSetString(hrec, 0, "[1] [2] [\\3asdf]");
1230 r = MsiRecordSetString(hrec, 1, "boo");
1231 r = MsiRecordSetString(hrec, 2, "hoo");
1232 ok( r == ERROR_SUCCESS, "set string failed\n");
1234 r = MsiFormatRecord(package, hrec, buffer, &sz);
1235 ok( r == ERROR_SUCCESS, "format failed\n");
1236 ok( sz == 9, "size wrong(%li)\n",sz);
1237 ok( 0 == strcmp(buffer,"boo hoo 3"), "wrong output (%s)\n",buffer);
1239 r = MsiRecordSetString(hrec, 0, "[1] [2] [\\x]");
1240 r = MsiRecordSetString(hrec, 1, "boo");
1241 r = MsiRecordSetString(hrec, 2, "hoo");
1242 ok( r == ERROR_SUCCESS, "set string failed\n");
1244 r = MsiFormatRecord(package, hrec, buffer, &sz);
1245 ok( r == ERROR_SUCCESS, "format failed\n");
1246 ok( sz == 9, "size wrong(%li)\n",sz);
1247 ok( 0 == strcmp(buffer,"boo hoo x"), "wrong output (%s)\n",buffer);
1249 /* null characters */
1250 r = MsiRecordSetString(hrec, 0, "[1] [~] [2]");
1251 r = MsiRecordSetString(hrec, 1, "boo");
1252 r = MsiRecordSetString(hrec, 2, "hoo");
1253 ok( r == ERROR_SUCCESS, "set string failed\n");
1255 r = MsiFormatRecord(package, hrec, buffer, &sz);
1256 ok( r == ERROR_SUCCESS, "format failed\n");
1257 ok( sz == 9, "size wrong\n");
1258 ok( 0 == strcmp(buffer,"boo "), "wrong output\n");
1261 r = MsiSetProperty(package,"dummy","Bork");
1262 ok( r == ERROR_SUCCESS, "set property failed\n");
1263 r = MsiRecordSetString(hrec, 0, "[1] [dummy] [2]");
1264 r = MsiRecordSetString(hrec, 1, "boo");
1265 r = MsiRecordSetString(hrec, 2, "hoo");
1266 ok( r == ERROR_SUCCESS, "set string failed\n");
1268 r = MsiFormatRecord(package, hrec, buffer, &sz);
1269 ok( r == ERROR_SUCCESS, "format failed\n");
1270 ok( sz == 12, "size wrong\n");
1271 ok( 0 == strcmp(buffer,"boo Bork hoo"), "wrong output\n");
1273 r = MsiRecordSetString(hrec, 0, "[1] [invalid] [2]");
1274 r = MsiRecordSetString(hrec, 1, "boo");
1275 r = MsiRecordSetString(hrec, 2, "hoo");
1276 ok( r == ERROR_SUCCESS, "set string failed\n");
1278 r = MsiFormatRecord(package, hrec, buffer, &sz);
1279 ok( r == ERROR_SUCCESS, "format failed\n");
1280 ok( sz == 8, "size wrong\n");
1281 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
1285 r = MsiSetProperty(package,"dummya","foo");
1286 r = MsiSetProperty(package,"dummyb","baa");
1287 r = MsiSetProperty(package,"adummyc","whoa");
1288 ok( r == ERROR_SUCCESS, "set property failed\n");
1289 r = MsiRecordSetString(hrec, 0, "[dummy[1]] [dummy[2]] [[1]dummy[3]]");
1290 r = MsiRecordSetString(hrec, 1, "a");
1291 r = MsiRecordSetString(hrec, 2, "b");
1292 r = MsiRecordSetString(hrec, 3, "c");
1293 ok( r == ERROR_SUCCESS, "set string failed\n");
1295 r = MsiFormatRecord(package, hrec, buffer, &sz);
1296 ok( r == ERROR_SUCCESS, "format failed\n");
1297 ok( sz == 12, "size wrong(%li)\n",sz);
1298 ok( 0 == strcmp(buffer,"foo baa whoa"), "wrong output (%s)\n",buffer);
1301 r = MsiSetProperty(package,"dummya","1");
1302 r = MsiSetProperty(package,"dummyb","[2]");
1303 ok( r == ERROR_SUCCESS, "set property failed\n");
1304 r = MsiRecordSetString(hrec, 0, "[dummya] [[dummya]] [dummyb]");
1305 r = MsiRecordSetString(hrec, 1, "aaa");
1306 r = MsiRecordSetString(hrec, 2, "bbb");
1307 r = MsiRecordSetString(hrec, 3, "ccc");
1308 ok( r == ERROR_SUCCESS, "set string failed\n");
1310 r = MsiFormatRecord(package, hrec, buffer, &sz);
1311 ok( r == ERROR_SUCCESS, "format failed\n");
1312 ok( sz == 9, "size wrong(%li)\n",sz);
1313 ok( 0 == strcmp(buffer,"1 [1] [2]"), "wrong output (%s)\n",buffer);
1315 r = MsiSetProperty(package,"dummya","1");
1316 r = MsiSetProperty(package,"dummyb","a");
1317 r = MsiSetProperty(package,"dummyc","\\blath");
1318 r = MsiSetProperty(package,"dummyd","[\\blath]");
1319 ok( r == ERROR_SUCCESS, "set property failed\n");
1320 r = MsiRecordSetString(hrec, 0, "[dummyc] [[dummyc]] [dummy[dummyb]]");
1321 r = MsiRecordSetString(hrec, 1, "aaa");
1322 r = MsiRecordSetString(hrec, 2, "bbb");
1323 r = MsiRecordSetString(hrec, 3, "ccc");
1324 ok( r == ERROR_SUCCESS, "set string failed\n");
1326 r = MsiFormatRecord(package, hrec, buffer, &sz);
1327 ok( r == ERROR_SUCCESS, "format failed\n");
1328 ok( sz == 10, "size wrong(%li)\n",sz);
1329 ok( 0 == strcmp(buffer,"\\blath b 1"), "wrong output (%s)\n",buffer);
1331 r = MsiRecordSetString(hrec, 0, "[1] [2] [[\\3asdf]]");
1332 r = MsiRecordSetString(hrec, 1, "boo");
1333 r = MsiRecordSetString(hrec, 2, "hoo");
1334 r = MsiRecordSetString(hrec, 3, "yeah");
1335 ok( r == ERROR_SUCCESS, "set string failed\n");
1337 r = MsiFormatRecord(package, hrec, buffer, &sz);
1338 ok( r == ERROR_SUCCESS, "format failed\n");
1339 ok( sz == 11, "size wrong(%li)\n",sz);
1340 ok( 0 == strcmp(buffer,"boo hoo [3]"), "wrong output (%s)\n",buffer);
1342 r = MsiRecordSetString(hrec, 0, "[1] [2] [[3]]");
1343 r = MsiRecordSetString(hrec, 1, "boo");
1344 r = MsiRecordSetString(hrec, 2, "hoo");
1345 r = MsiRecordSetString(hrec, 3, "\\help");
1346 ok( r == ERROR_SUCCESS, "set string failed\n");
1348 r = MsiFormatRecord(package, hrec, buffer, &sz);
1349 ok( r == ERROR_SUCCESS, "format failed\n");
1350 ok( sz == 9, "size wrong(%li)\n",sz);
1351 ok( 0 == strcmp(buffer,"boo hoo h"), "wrong output (%s)\n",buffer);
1353 MsiCloseHandle(hrec);
1355 r = MsiCloseHandle(package);
1356 ok(r==ERROR_SUCCESS, "Unable to close package\n");
1358 DeleteFile( filename );
1363 test_createpackage();
1364 test_formatrecord();
1365 test_formatrecord_package();