Release 1.1.8.
[wine/multimedia.git] / dlls / msi / tests / format.c
blobc4be4294650747ac9ed4c8c8a907b53e5d2806b4
1 /*
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
22 #include <stdio.h>
23 #include <windows.h>
24 #include <shlwapi.h>
25 #include <msi.h>
26 #include <msiquery.h>
28 #include "wine/test.h"
30 static const char msifile[] = "winetest.msi";
32 static UINT run_query( MSIHANDLE hdb, const char *query )
34 MSIHANDLE hview = 0;
35 UINT r;
37 r = MsiDatabaseOpenView(hdb, query, &hview);
38 if( r != ERROR_SUCCESS )
39 return r;
41 r = MsiViewExecute(hview, 0);
42 if( r == ERROR_SUCCESS )
43 r = MsiViewClose(hview);
44 MsiCloseHandle(hview);
45 return r;
48 static UINT create_feature_table( MSIHANDLE hdb )
50 return run_query( hdb,
51 "CREATE TABLE `Feature` ( "
52 "`Feature` CHAR(38) NOT NULL, "
53 "`Feature_Parent` CHAR(38), "
54 "`Title` CHAR(64), "
55 "`Description` CHAR(255), "
56 "`Display` SHORT NOT NULL, "
57 "`Level` SHORT NOT NULL, "
58 "`Directory_` CHAR(72), "
59 "`Attributes` SHORT NOT NULL "
60 "PRIMARY KEY `Feature`)" );
63 static UINT create_component_table( MSIHANDLE hdb )
65 return run_query( hdb,
66 "CREATE TABLE `Component` ( "
67 "`Component` CHAR(72) NOT NULL, "
68 "`ComponentId` CHAR(38), "
69 "`Directory_` CHAR(72) NOT NULL, "
70 "`Attributes` SHORT NOT NULL, "
71 "`Condition` CHAR(255), "
72 "`KeyPath` CHAR(72) "
73 "PRIMARY KEY `Component`)" );
76 static UINT create_feature_components_table( MSIHANDLE hdb )
78 return run_query( hdb,
79 "CREATE TABLE `FeatureComponents` ( "
80 "`Feature_` CHAR(38) NOT NULL, "
81 "`Component_` CHAR(72) NOT NULL "
82 "PRIMARY KEY `Feature_`, `Component_` )" );
85 static UINT create_file_table( MSIHANDLE hdb )
87 return run_query( hdb,
88 "CREATE TABLE `File` ("
89 "`File` CHAR(72) NOT NULL, "
90 "`Component_` CHAR(72) NOT NULL, "
91 "`FileName` CHAR(255) NOT NULL, "
92 "`FileSize` LONG NOT NULL, "
93 "`Version` CHAR(72), "
94 "`Language` CHAR(20), "
95 "`Attributes` SHORT, "
96 "`Sequence` SHORT NOT NULL "
97 "PRIMARY KEY `File`)" );
100 static UINT create_custom_action_table( MSIHANDLE hdb )
102 return run_query( hdb,
103 "CREATE TABLE `CustomAction` ("
104 "`Action` CHAR(72) NOT NULL, "
105 "`Type` SHORT NOT NULL, "
106 "`Source` CHAR(75), "
107 "`Target` CHAR(255) "
108 "PRIMARY KEY `Action`)" );
111 #define make_add_entry(type, qtext) \
112 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
114 char insert[] = qtext; \
115 char *query; \
116 UINT sz, r; \
117 sz = strlen(values) + sizeof insert; \
118 query = HeapAlloc(GetProcessHeap(),0,sz); \
119 sprintf(query,insert,values); \
120 r = run_query( hdb, query ); \
121 HeapFree(GetProcessHeap(), 0, query); \
122 return r; \
125 make_add_entry(feature,
126 "INSERT INTO `Feature` "
127 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
128 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
130 make_add_entry(component,
131 "INSERT INTO `Component` "
132 "(`Component`, `ComponentId`, `Directory_`, "
133 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
135 make_add_entry(feature_components,
136 "INSERT INTO `FeatureComponents` "
137 "(`Feature_`, `Component_`) VALUES( %s )")
139 make_add_entry(file,
140 "INSERT INTO `File` "
141 "(`File`, `Component_`, `FileName`, `FileSize`, "
142 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
144 make_add_entry(directory,
145 "INSERT INTO `Directory` "
146 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
148 make_add_entry(custom_action,
149 "INSERT INTO `CustomAction` "
150 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
152 static UINT set_summary_info(MSIHANDLE hdb)
154 UINT res;
155 MSIHANDLE suminfo;
157 /* build summary info */
158 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
159 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
161 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
162 "Installation Database");
163 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
165 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
166 "Installation Database");
167 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
169 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
170 "Wine Hackers");
171 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
173 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
174 ";1033");
175 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
177 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
178 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
179 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
181 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
182 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
184 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
185 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
187 res = MsiSummaryInfoPersist(suminfo);
188 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
190 res = MsiCloseHandle( suminfo);
191 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
193 return res;
196 static MSIHANDLE create_package_db(void)
198 MSIHANDLE hdb = 0;
199 UINT res;
201 DeleteFile(msifile);
203 /* create an empty database */
204 res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
205 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
206 if( res != ERROR_SUCCESS )
207 return hdb;
209 res = MsiDatabaseCommit( hdb );
210 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
212 res = set_summary_info(hdb);
214 res = run_query( hdb,
215 "CREATE TABLE `Directory` ( "
216 "`Directory` CHAR(255) NOT NULL, "
217 "`Directory_Parent` CHAR(255), "
218 "`DefaultDir` CHAR(255) NOT NULL "
219 "PRIMARY KEY `Directory`)" );
220 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
222 return hdb;
225 static MSIHANDLE package_from_db(MSIHANDLE hdb)
227 UINT res;
228 CHAR szPackage[10];
229 MSIHANDLE hPackage;
231 sprintf(szPackage,"#%li",hdb);
232 res = MsiOpenPackage(szPackage,&hPackage);
233 ok( res == ERROR_SUCCESS , "Failed to open package\n" );
235 res = MsiCloseHandle(hdb);
236 ok( res == ERROR_SUCCESS , "Failed to close db handle\n" );
238 return hPackage;
241 static void create_test_file(const CHAR *name)
243 HANDLE file;
244 DWORD written;
246 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
247 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
248 WriteFile(file, name, strlen(name), &written, NULL);
249 WriteFile(file, "\n", strlen("\n"), &written, NULL);
250 CloseHandle(file);
253 static MSIHANDLE helper_createpackage( const char *szName )
255 MSIHANDLE hdb = 0;
256 UINT res;
257 CHAR szPackage[10];
258 MSIHANDLE hPackage;
259 MSIHANDLE suminfo;
261 DeleteFile(szName);
263 /* create an empty database */
264 res = MsiOpenDatabase(szName, MSIDBOPEN_CREATE, &hdb );
265 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
267 res = MsiDatabaseCommit( hdb );
268 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
270 /* build summary info */
271 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
272 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
274 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
275 "Installation Database");
276 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
278 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
279 "Installation Database");
280 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
282 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
283 "Wine Hackers");
284 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
286 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
287 ";1033");
288 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
290 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
291 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
292 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
294 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
295 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
297 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
298 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
300 res = MsiSummaryInfoPersist(suminfo);
301 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
303 res = MsiCloseHandle( suminfo);
304 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
306 sprintf(szPackage,"#%li",hdb);
307 res = MsiOpenPackage(szPackage,&hPackage);
308 ok( res == ERROR_SUCCESS , "Failed to open package\n" );
310 res = MsiCloseHandle( hdb );
311 ok( res == ERROR_SUCCESS , "Failed to close database\n" );
313 return hPackage;
316 static void test_createpackage(void)
318 static const CHAR filename[] = "winetest.msi";
319 MSIHANDLE hPackage = 0;
320 UINT res;
322 hPackage = helper_createpackage( filename );
323 ok ( hPackage != 0, " Failed to create package\n");
325 res = MsiCloseHandle( hPackage);
326 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
328 DeleteFile( filename );
331 static void test_formatrecord(void)
333 char buffer[100];
334 MSIHANDLE hrec;
335 UINT r;
336 DWORD sz;
338 r = MsiFormatRecord(0, 0, NULL, NULL );
339 ok( r == ERROR_INVALID_HANDLE, "wrong error\n");
341 hrec = MsiCreateRecord(0);
342 ok( hrec, "failed to create record\n");
344 /* format an empty record on a record with no parameters */
345 sz = sizeof(buffer);
346 r = MsiFormatRecordA(0, hrec, buffer, &sz );
347 ok( r == ERROR_SUCCESS, "format failed\n");
348 ok( sz == 0, "size wrong\n");
350 MsiCloseHandle( hrec );
352 hrec = MsiCreateRecord(4);
353 ok( hrec, "failed to create record\n");
355 /* format an empty record */
356 r = MsiFormatRecord(0, hrec, NULL, NULL );
357 ok( r == ERROR_SUCCESS, "format failed\n");
358 buffer[0] = 'x';
359 buffer[1] = 0;
360 sz=0;
361 r = MsiFormatRecord(0, hrec, buffer+1, &sz);
362 ok( r == ERROR_MORE_DATA && buffer[0] == 'x', "format failed measuring with buffer\n");
363 ok( sz == 16, "size wrong\n");
364 sz=100;
365 r = MsiFormatRecord(0, hrec, buffer, &sz);
366 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
367 ok( sz == 16, "size wrong\n");
368 ok( 0 == strcmp(buffer,"1: 2: 3: 4: "), "wrong output\n");
370 r = MsiCloseHandle(hrec);
371 ok(r==ERROR_SUCCESS, "Unable to close record\n");
373 hrec = MsiCreateRecord(6);
374 ok( hrec, "failed to create record\n");
376 sz = 100;
377 buffer[0] = 'x';
378 buffer[1] = 0;
379 r = MsiFormatRecord(0, hrec, buffer, &sz);
380 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
381 ok( sz == 24, "size wrong\n");
382 ok( 0 == strcmp(buffer,"1: 2: 3: 4: 5: 6: "), "wrong output\n");
385 /* format a format string with everything else empty */
386 r = MsiRecordSetString(hrec, 0, "%1");
387 ok( r == ERROR_SUCCESS, "set string failed\n");
388 r = MsiFormatRecord(0, hrec, NULL, NULL );
389 ok( r == ERROR_SUCCESS, "format failed\n");
390 r = MsiFormatRecord(0, hrec, buffer, NULL);
391 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
393 sz = 123;
394 r = MsiFormatRecord(0, hrec, NULL, &sz);
395 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
396 ok( sz == 2, "size wrong (%i)\n",sz);
397 sz = sizeof buffer;
398 buffer[0] = 'x';
399 buffer[1] = 0;
400 r = MsiFormatRecord(0, hrec, buffer, &sz);
401 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
402 ok( sz == 2, "size wrong\n");
403 ok( 0 == strcmp(buffer,"%1"), "wrong output\n");
405 /* make the buffer too small */
406 sz = 0;
407 buffer[0] = 'x';
408 buffer[1] = 0;
409 r = MsiFormatRecord(0, hrec, buffer, &sz);
410 ok( r == ERROR_MORE_DATA, "format failed with empty buffer\n");
411 ok( sz == 2, "size wrong\n");
412 ok( 0 == strcmp(buffer,"x"), "wrong output\n");
414 /* make the buffer a little bit bigger */
415 sz = 1;
416 buffer[0] = 'x';
417 buffer[1] = 0;
418 r = MsiFormatRecord(0, hrec, buffer, &sz);
419 ok( r == ERROR_MORE_DATA, "format failed with empty buffer\n");
420 ok( sz == 2, "size wrong\n");
421 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
423 /* and again */
424 sz = 2;
425 buffer[0] = 'x';
426 buffer[1] = 0;
427 r = MsiFormatRecord(0, hrec, buffer, &sz);
428 ok( r == ERROR_MORE_DATA, "format failed with empty buffer\n");
429 ok( sz == 2, "size wrong\n");
430 ok( 0 == strcmp(buffer,"%"), "wrong output\n");
432 /* and again */
433 sz = 3;
434 buffer[0] = 'x';
435 buffer[1] = 0;
436 r = MsiFormatRecord(0, hrec, buffer, &sz);
437 ok( r == ERROR_SUCCESS, "format failed with empty buffer\n");
438 ok( sz == 2, "size wrong\n");
439 ok( 0 == strcmp(buffer,"%1"), "wrong output\n");
441 /* now try a real format string */
442 r = MsiRecordSetString(hrec, 0, "[1]");
443 ok( r == ERROR_SUCCESS, "set string failed\n");
444 sz = sizeof buffer;
445 r = MsiFormatRecord(0, hrec, buffer, &sz);
446 ok( r == ERROR_SUCCESS, "format failed\n");
447 ok( sz == 0, "size wrong\n");
448 ok( 0 == strcmp(buffer,""), "wrong output\n");
450 /* now put something in the first field */
451 r = MsiRecordSetString(hrec, 1, "boo hoo");
452 ok( r == ERROR_SUCCESS, "set string failed\n");
453 sz = sizeof buffer;
454 r = MsiFormatRecord(0, hrec, buffer, &sz);
455 ok( r == ERROR_SUCCESS, "format failed\n");
456 ok( sz == 7, "size wrong\n");
457 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
459 /* now put something in the first field */
460 r = MsiRecordSetString(hrec, 0, "[1] [2]");
461 r = MsiRecordSetString(hrec, 1, "boo");
462 r = MsiRecordSetString(hrec, 2, "hoo");
463 ok( r == ERROR_SUCCESS, "set string failed\n");
464 sz = sizeof buffer;
465 r = MsiFormatRecord(0, hrec, buffer, &sz);
466 ok( r == ERROR_SUCCESS, "format failed\n");
467 ok( sz == 7, "size wrong\n");
468 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
470 /* empty string */
471 r = MsiRecordSetString(hrec, 0, "");
472 sz = sizeof buffer;
473 r = MsiFormatRecord(0, hrec, buffer, &sz);
474 ok( r == ERROR_SUCCESS, "format failed\n");
475 ok( sz == 30, "size wrong %i\n",sz);
476 ok( 0 == strcmp(buffer,"1: boo 2: hoo 3: 4: 5: 6: "),
477 "wrong output(%s)\n",buffer);
479 /* play games with recursive lookups */
480 r = MsiRecordSetString(hrec, 0, "[[1]] [2]");
481 r = MsiRecordSetString(hrec, 1, "2");
482 r = MsiRecordSetString(hrec, 2, "hey");
483 ok( r == ERROR_SUCCESS, "set string failed\n");
484 sz = sizeof buffer;
485 r = MsiFormatRecord(0, hrec, buffer, &sz);
486 ok( r == ERROR_SUCCESS, "format failed\n");
487 ok( sz == 7, "size wrong,(%i)\n",sz);
488 ok( 0 == strcmp(buffer,"hey hey"), "wrong output (%s)\n",buffer);
490 r = MsiRecordSetString(hrec, 0, "[[1]] [2]");
491 r = MsiRecordSetString(hrec, 1, "[2]");
492 r = MsiRecordSetString(hrec, 2, "hey");
493 ok( r == ERROR_SUCCESS, "set string failed\n");
494 sz = sizeof buffer;
495 r = MsiFormatRecord(0, hrec, buffer, &sz);
496 ok( r == ERROR_SUCCESS, "format failed\n");
497 ok( sz == 9, "size wrong,(%i)\n",sz);
498 ok( 0 == strcmp(buffer,"[[2]] hey"), "wrong output (%s)\n",buffer);
500 r = MsiRecordSetString(hrec, 0, "[[[3]]] [2]");
501 r = MsiRecordSetString(hrec, 1, "2");
502 r = MsiRecordSetString(hrec, 2, "hey");
503 r = MsiRecordSetString(hrec, 3, "1");
504 ok( r == ERROR_SUCCESS, "set string failed\n");
505 sz = sizeof buffer;
506 r = MsiFormatRecord(0, hrec, buffer, &sz);
507 ok( r == ERROR_SUCCESS, "format failed\n");
508 ok( sz == 7, "size wrong,(%i)\n",sz);
509 ok( 0 == strcmp(buffer,"hey hey"), "wrong output (%s)\n",buffer);
511 r = MsiCloseHandle(hrec);
512 ok(r==ERROR_SUCCESS, "Unable to close record\n");
513 hrec = MsiCreateRecord(12);
514 ok( hrec, "failed to create record\n");
516 r = MsiRecordSetString(hrec, 0, "[[3][1]] [2]");
517 r = MsiRecordSetString(hrec, 1, "2");
518 r = MsiRecordSetString(hrec, 2, "hey");
519 r = MsiRecordSetString(hrec, 3, "1");
520 r = MsiRecordSetString(hrec, 12, "big");
521 ok( r == ERROR_SUCCESS, "set string failed\n");
522 sz = sizeof buffer;
523 r = MsiFormatRecord(0, hrec, buffer, &sz);
524 ok( r == ERROR_SUCCESS, "format failed\n");
525 ok( sz == 7, "size wrong,(%i)\n",sz);
526 ok( 0 == strcmp(buffer,"big hey"), "wrong output (%s)\n",buffer);
528 r = MsiRecordSetString(hrec, 0, "[[3][4][1]] [2]");
529 r = MsiRecordSetString(hrec, 1, "2");
530 r = MsiRecordSetString(hrec, 2, "hey");
531 r = MsiRecordSetString(hrec, 3, "1");
532 r = MsiRecordSetString(hrec, 4, NULL);
533 r = MsiRecordSetString(hrec, 12, "big");
534 ok( r == ERROR_SUCCESS, "set string failed\n");
535 sz = sizeof buffer;
536 r = MsiFormatRecord(0, hrec, buffer, &sz);
537 ok( r == ERROR_SUCCESS, "format failed\n");
538 ok( sz == 7, "size wrong,(%i)\n",sz);
539 ok( 0 == strcmp(buffer,"big hey"), "wrong output (%s)\n",buffer);
541 r = MsiRecordSetString(hrec, 0, "[[3][[4]][1]] [2]");
542 r = MsiRecordSetString(hrec, 1, "2");
543 r = MsiRecordSetString(hrec, 2, "hey");
544 r = MsiRecordSetString(hrec, 3, "1");
545 r = MsiRecordSetString(hrec, 4, NULL);
546 r = MsiRecordSetString(hrec, 12, "big");
547 ok( r == ERROR_SUCCESS, "set string failed\n");
548 sz = sizeof buffer;
549 r = MsiFormatRecord(0, hrec, buffer, &sz);
550 ok( r == ERROR_SUCCESS, "format failed\n");
551 ok( sz == 10, "size wrong,(%i)\n",sz);
552 ok( 0 == strcmp(buffer,"[1[]2] hey"), "wrong output (%s)\n",buffer);
554 /* incorrect formats */
555 r = MsiRecordSetString(hrec, 0, "[[[3][[4]][1]] [2]");
556 r = MsiRecordSetString(hrec, 1, "2");
557 r = MsiRecordSetString(hrec, 2, "hey");
558 r = MsiRecordSetString(hrec, 3, "1");
559 r = MsiRecordSetString(hrec, 4, NULL);
560 r = MsiRecordSetString(hrec, 12, "big");
561 ok( r == ERROR_SUCCESS, "set string failed\n");
562 sz = sizeof buffer;
563 r = MsiFormatRecord(0, hrec, buffer, &sz);
564 ok( r == ERROR_SUCCESS, "format failed\n");
565 ok( sz == 18, "size wrong,(%i)\n",sz);
566 ok( 0 == strcmp(buffer,"[[[3][[4]][1]] [2]"), "wrong output (%s)\n",buffer);
568 r = MsiRecordSetString(hrec, 0, "[[3][[4]][1]] [2]]");
569 r = MsiRecordSetString(hrec, 1, "2");
570 r = MsiRecordSetString(hrec, 2, "hey");
571 r = MsiRecordSetString(hrec, 3, "1");
572 r = MsiRecordSetString(hrec, 4, NULL);
573 r = MsiRecordSetString(hrec, 12, "big");
574 ok( r == ERROR_SUCCESS, "set string failed\n");
575 sz = sizeof buffer;
576 r = MsiFormatRecord(0, hrec, buffer, &sz);
577 ok( r == ERROR_SUCCESS, "format failed\n");
578 ok( sz == 11, "size wrong,(%i)\n",sz);
579 ok( 0 == strcmp(buffer,"[1[]2] hey]"), "wrong output (%s)\n",buffer);
582 /* play games with {} */
584 r = MsiRecordSetString(hrec, 0, "{[3][1]} [2]");
585 r = MsiRecordSetString(hrec, 1, "2");
586 r = MsiRecordSetString(hrec, 2, "hey");
587 r = MsiRecordSetString(hrec, 3, "1");
588 r = MsiRecordSetString(hrec, 4, NULL);
589 r = MsiRecordSetString(hrec, 12, "big");
590 ok( r == ERROR_SUCCESS, "set string failed\n");
591 sz = sizeof buffer;
592 r = MsiFormatRecord(0, hrec, buffer, &sz);
593 ok( r == ERROR_SUCCESS, "format failed\n");
594 ok( sz == 6, "size wrong,(%i)\n",sz);
595 ok( 0 == strcmp(buffer,"12 hey"), "wrong output (%s)\n",buffer);
597 r = MsiRecordSetString(hrec, 0, "[{[3][1]}] [2]");
598 r = MsiRecordSetString(hrec, 1, "2");
599 r = MsiRecordSetString(hrec, 2, "hey");
600 r = MsiRecordSetString(hrec, 3, "1");
601 r = MsiRecordSetString(hrec, 4, NULL);
602 r = MsiRecordSetString(hrec, 12, "big");
603 ok( r == ERROR_SUCCESS, "set string failed\n");
604 sz = sizeof buffer;
605 r = MsiFormatRecord(0, hrec, buffer, &sz);
606 ok( r == ERROR_SUCCESS, "format failed\n");
607 ok( sz == 8, "size wrong,(%i)\n",sz);
608 ok( 0 == strcmp(buffer,"[12] hey"), "wrong output (%s)\n",buffer);
611 r = MsiRecordSetString(hrec, 0, "{test} [2]");
612 r = MsiRecordSetString(hrec, 1, "2");
613 r = MsiRecordSetString(hrec, 2, "hey");
614 r = MsiRecordSetString(hrec, 3, "1");
615 r = MsiRecordSetString(hrec, 4, NULL);
616 r = MsiRecordSetString(hrec, 12, "big");
617 ok( r == ERROR_SUCCESS, "set string failed\n");
618 sz = sizeof buffer;
619 r = MsiFormatRecord(0, hrec, buffer, &sz);
620 ok( r == ERROR_SUCCESS, "format failed\n");
621 ok( sz == 10, "size wrong,(%i)\n",sz);
622 ok( 0 == strcmp(buffer,"{test} hey"), "wrong output (%s)\n",buffer);
624 r = MsiRecordSetString(hrec, 0, "{[test]} [2]");
625 r = MsiRecordSetString(hrec, 1, "2");
626 r = MsiRecordSetString(hrec, 2, "hey");
627 r = MsiRecordSetString(hrec, 3, "1");
628 r = MsiRecordSetString(hrec, 4, NULL);
629 r = MsiRecordSetString(hrec, 12, "big");
630 ok( r == ERROR_SUCCESS, "set string failed\n");
631 sz = sizeof buffer;
632 r = MsiFormatRecord(0, hrec, buffer, &sz);
633 ok( r == ERROR_SUCCESS, "format failed\n");
634 ok( sz == 12, "size wrong,(%i)\n",sz);
635 ok( 0 == strcmp(buffer,"{[test]} hey"), "wrong output (%s)\n",buffer);
637 r = MsiRecordSetString(hrec, 0, "{[1][2][3][4]} [2]");
638 r = MsiRecordSetString(hrec, 1, "2");
639 r = MsiRecordSetString(hrec, 2, "hey");
640 r = MsiRecordSetString(hrec, 3, "1");
641 r = MsiRecordSetString(hrec, 4, NULL);
642 r = MsiRecordSetString(hrec, 12, "big");
643 ok( r == ERROR_SUCCESS, "set string failed\n");
644 sz = sizeof buffer;
645 r = MsiFormatRecord(0, hrec, buffer, &sz);
646 ok( r == ERROR_SUCCESS, "format failed\n");
647 ok( sz == 4, "size wrong,(%i)\n",sz);
648 ok( 0 == strcmp(buffer," hey"), "wrong output (%s)\n",buffer);
650 r = MsiRecordSetString(hrec, 0, "{[1][2][3][dummy]} [2]");
651 r = MsiRecordSetString(hrec, 1, "2");
652 r = MsiRecordSetString(hrec, 2, "hey");
653 r = MsiRecordSetString(hrec, 3, "1");
654 r = MsiRecordSetString(hrec, 4, NULL);
655 r = MsiRecordSetString(hrec, 12, "big");
656 ok( r == ERROR_SUCCESS, "set string failed\n");
657 sz = sizeof buffer;
658 r = MsiFormatRecord(0, hrec, buffer, &sz);
659 ok( r == ERROR_SUCCESS, "format failed\n");
660 ok( sz == 18, "size wrong,(%i)\n",sz);
661 ok( 0 == strcmp(buffer,"{2hey1[dummy]} hey"), "wrong output (%s)\n",buffer);
663 r = MsiRecordSetString(hrec, 0, "{[1][2][3][4][dummy]} [2]");
664 r = MsiRecordSetString(hrec, 1, "2");
665 r = MsiRecordSetString(hrec, 2, "hey");
666 r = MsiRecordSetString(hrec, 3, "1");
667 r = MsiRecordSetString(hrec, 4, NULL);
668 r = MsiRecordSetString(hrec, 12, "big");
669 ok( r == ERROR_SUCCESS, "set string failed\n");
670 sz = sizeof buffer;
671 r = MsiFormatRecord(0, hrec, buffer, &sz);
672 ok( r == ERROR_SUCCESS, "format failed\n");
673 ok( sz == 18, "size wrong,(%i)\n",sz);
674 ok( 0 == strcmp(buffer,"{2hey1[dummy]} hey"), "wrong output (%s)\n",buffer);
676 r = MsiRecordSetString(hrec, 0, "{{[1][2]}[3][4][dummy]}");
677 r = MsiRecordSetString(hrec, 1, "2");
678 r = MsiRecordSetString(hrec, 2, "hey");
679 r = MsiRecordSetString(hrec, 3, "1");
680 r = MsiRecordSetString(hrec, 4, NULL);
681 r = MsiRecordSetString(hrec, 12, "big");
682 ok( r == ERROR_SUCCESS, "set string failed\n");
683 sz = sizeof buffer;
684 r = MsiFormatRecord(0, hrec, buffer, &sz);
685 ok( r == ERROR_SUCCESS, "format failed\n");
686 ok( sz == 16, "size wrong,(%i)\n",sz);
687 ok( 0 == strcmp(buffer,"{{2hey}1[dummy]}"), "wrong output (%s)\n",buffer);
689 r = MsiRecordSetString(hrec, 0, "{{[1][2]}[3]{[4][dummy]}}");
690 r = MsiRecordSetString(hrec, 1, "2");
691 r = MsiRecordSetString(hrec, 2, "hey");
692 r = MsiRecordSetString(hrec, 3, "1");
693 r = MsiRecordSetString(hrec, 4, NULL);
694 r = MsiRecordSetString(hrec, 12, "big");
695 ok( r == ERROR_SUCCESS, "set string failed\n");
696 sz = sizeof buffer;
697 r = MsiFormatRecord(0, hrec, buffer, &sz);
698 ok( r == ERROR_SUCCESS, "format failed\n");
699 ok( sz == 0, "size wrong,(%i)\n",sz);
700 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
702 r = MsiRecordSetString(hrec, 0, "{{[1][2]}[3]} {[1][2]}");
703 r = MsiRecordSetString(hrec, 1, "1");
704 r = MsiRecordSetString(hrec, 2, "2");
705 r = MsiRecordSetString(hrec, 3, "3");
706 r = MsiRecordSetString(hrec, 4, NULL);
707 r = MsiRecordSetString(hrec, 12, "big");
708 ok( r == ERROR_SUCCESS, "set string failed\n");
709 sz = sizeof buffer;
710 r = MsiFormatRecord(0, hrec, buffer, &sz);
711 ok( r == ERROR_SUCCESS, "format failed\n");
712 ok( sz == 12, "size wrong,(%i)\n",sz);
713 ok( 0 == strcmp(buffer,"{{12}3} {12}"), "wrong output (%s)\n",buffer);
715 r = MsiRecordSetString(hrec, 0, "{[1][2]} {{[1][2]}[3]} {[1][2]}");
716 r = MsiRecordSetString(hrec, 1, "1");
717 r = MsiRecordSetString(hrec, 2, "2");
718 r = MsiRecordSetString(hrec, 3, "3");
719 r = MsiRecordSetString(hrec, 4, NULL);
720 r = MsiRecordSetString(hrec, 12, "big");
721 ok( r == ERROR_SUCCESS, "set string failed\n");
722 sz = sizeof buffer;
723 r = MsiFormatRecord(0, hrec, buffer, &sz);
724 ok( r == ERROR_SUCCESS, "format failed\n");
725 ok( sz == 15, "size wrong,(%i)\n",sz);
726 ok( 0 == strcmp(buffer,"12 {{12}3} {12}"), "wrong output (%s)\n",buffer);
728 r = MsiRecordSetString(hrec, 0, "{[4]}{[1][2]} {{[1][2]}[3]} {[1][2]}");
729 r = MsiRecordSetString(hrec, 1, "1");
730 r = MsiRecordSetString(hrec, 2, "2");
731 r = MsiRecordSetString(hrec, 3, "3");
732 r = MsiRecordSetString(hrec, 4, NULL);
733 r = MsiRecordSetString(hrec, 12, "big");
734 ok( r == ERROR_SUCCESS, "set string failed\n");
735 sz = sizeof buffer;
736 r = MsiFormatRecord(0, hrec, buffer, &sz);
737 ok( r == ERROR_SUCCESS, "format failed\n");
738 ok( sz == 15, "size wrong,(%i)\n",sz);
739 ok( 0 == strcmp(buffer,"12 {{12}3} {12}"), "wrong output (%s)\n",buffer);
741 r = MsiRecordSetString(hrec, 0, "{blah} {[4]}{[1][2]} {{[1][2]}[3]} {[1][2]}");
742 r = MsiRecordSetString(hrec, 1, "1");
743 r = MsiRecordSetString(hrec, 2, "2");
744 r = MsiRecordSetString(hrec, 3, "3");
745 r = MsiRecordSetString(hrec, 4, NULL);
746 r = MsiRecordSetString(hrec, 12, "big");
747 ok( r == ERROR_SUCCESS, "set string failed\n");
748 sz = sizeof buffer;
749 r = MsiFormatRecord(0, hrec, buffer, &sz);
750 ok( r == ERROR_SUCCESS, "format failed\n");
751 ok( sz == 22, "size wrong,(%i)\n",sz);
752 ok( 0 == strcmp(buffer,"{blah} 12 {{12}3} {12}"), "wrong output (%s)\n",buffer);
754 r = MsiRecordSetString(hrec, 0, "{{[1]}[2]} {[4]}{[1][2]}");
755 r = MsiRecordSetString(hrec, 1, "1");
756 r = MsiRecordSetString(hrec, 2, "2");
757 r = MsiRecordSetString(hrec, 3, "3");
758 r = MsiRecordSetString(hrec, 4, NULL);
759 r = MsiRecordSetString(hrec, 12, "big");
760 ok( r == ERROR_SUCCESS, "set string failed\n");
761 sz = sizeof buffer;
762 r = MsiFormatRecord(0, hrec, buffer, &sz);
763 ok( r == ERROR_SUCCESS, "format failed\n");
764 ok( sz == 13, "size wrong,(%i)\n",sz);
765 ok( 0 == strcmp(buffer,"{{1}2} {}{12}"), "wrong output (%s)\n",buffer);
767 r = MsiRecordSetString(hrec, 0, "{{[1]}} {[4]}{[1][2]}");
768 r = MsiRecordSetString(hrec, 1, "1");
769 r = MsiRecordSetString(hrec, 2, "2");
770 r = MsiRecordSetString(hrec, 3, "3");
771 r = MsiRecordSetString(hrec, 4, NULL);
772 r = MsiRecordSetString(hrec, 12, "big");
773 ok( r == ERROR_SUCCESS, "set string failed\n");
774 sz = sizeof buffer;
775 r = MsiFormatRecord(0, hrec, buffer, &sz);
776 ok( r == ERROR_SUCCESS, "format failed\n");
777 ok( sz == 3, "size wrong,(%i)\n",sz);
778 ok( 0 == strcmp(buffer," 12"), "wrong output (%s)\n",buffer);
780 r = MsiRecordSetString(hrec, 0, "{{{[1]}} {[4]}{[1][2]}");
781 r = MsiRecordSetString(hrec, 1, "1");
782 r = MsiRecordSetString(hrec, 2, "2");
783 r = MsiRecordSetString(hrec, 3, "3");
784 r = MsiRecordSetString(hrec, 4, NULL);
785 r = MsiRecordSetString(hrec, 12, "big");
786 ok( r == ERROR_SUCCESS, "set string failed\n");
787 sz = sizeof buffer;
788 r = MsiFormatRecord(0, hrec, buffer, &sz);
789 ok( r == ERROR_SUCCESS, "format failed\n");
790 todo_wine{
791 ok( sz == 3, "size wrong,(%i)\n",sz);
792 ok( 0 == strcmp(buffer," 12"), "wrong output (%s)\n",buffer);
795 /* now put play games with escaping */
796 r = MsiRecordSetString(hrec, 0, "[1] [2] [\\3asdf]");
797 r = MsiRecordSetString(hrec, 1, "boo");
798 r = MsiRecordSetString(hrec, 2, "hoo");
799 ok( r == ERROR_SUCCESS, "set string failed\n");
800 sz = sizeof buffer;
801 r = MsiFormatRecord(0, hrec, buffer, &sz);
802 ok( r == ERROR_SUCCESS, "format failed\n");
803 ok( sz == 16, "size wrong\n");
804 ok( 0 == strcmp(buffer,"boo hoo [\\3asdf]"), "wrong output\n");
806 /* now put play games with escaping */
807 r = MsiRecordSetString(hrec, 0, "[1] [2] [\\x]");
808 r = MsiRecordSetString(hrec, 1, "boo");
809 r = MsiRecordSetString(hrec, 2, "hoo");
810 ok( r == ERROR_SUCCESS, "set string failed\n");
811 sz = sizeof buffer;
812 r = MsiFormatRecord(0, hrec, buffer, &sz);
813 ok( r == ERROR_SUCCESS, "format failed\n");
814 ok( sz == 12, "size wrong\n");
815 ok( 0 == strcmp(buffer,"boo hoo [\\x]"), "wrong output\n");
817 MsiRecordSetString(hrec, 0, "[\\x]");
818 sz = sizeof buffer;
819 r = MsiFormatRecord(0, hrec, buffer, &sz);
820 ok( r == ERROR_SUCCESS, "format failed\n");
821 ok( sz == 4, "size wrong: %d\n", sz);
822 ok( 0 == strcmp(buffer,"[\\x]"), "wrong output: %s\n", buffer);
824 MsiRecordSetString(hrec, 0, "{\\x}");
825 sz = sizeof buffer;
826 r = MsiFormatRecord(0, hrec, buffer, &sz);
827 ok( r == ERROR_SUCCESS, "format failed\n");
828 ok( sz == 4, "size wrong: %d\n", sz);
829 ok( 0 == strcmp(buffer,"{\\x}"), "wrong output: %s\n", buffer);
831 MsiRecordSetString(hrec, 0, "[abc\\x]");
832 sz = sizeof buffer;
833 r = MsiFormatRecord(0, hrec, buffer, &sz);
834 ok( r == ERROR_SUCCESS, "format failed\n");
835 ok( sz == 7, "size wrong: %d\n", sz);
836 ok( 0 == strcmp(buffer,"[abc\\x]"), "wrong output: %s\n", buffer);
838 MsiRecordSetString(hrec, 0, "[\\[]Bracket Text[\\]]");
839 sz = sizeof buffer;
840 r = MsiFormatRecord(0, hrec, buffer, &sz);
841 ok( r == ERROR_SUCCESS, "format failed\n");
842 ok( sz == 20, "size wrong: %d\n", sz);
843 ok( 0 == strcmp(buffer,"[\\[]Bracket Text[\\]]"), "wrong output: %s\n", buffer);
845 /* now try other formats without a package */
846 r = MsiRecordSetString(hrec, 0, "[1] [2] [property]");
847 r = MsiRecordSetString(hrec, 1, "boo");
848 r = MsiRecordSetString(hrec, 2, "hoo");
849 ok( r == ERROR_SUCCESS, "set string failed\n");
850 sz = sizeof buffer;
851 r = MsiFormatRecord(0, hrec, buffer, &sz);
852 ok( r == ERROR_SUCCESS, "format failed\n");
853 ok( sz == 18, "size wrong\n");
854 ok( 0 == strcmp(buffer,"boo hoo [property]"), "wrong output\n");
856 r = MsiRecordSetString(hrec, 0, "[1] [~] [2]");
857 r = MsiRecordSetString(hrec, 1, "boo");
858 r = MsiRecordSetString(hrec, 2, "hoo");
859 ok( r == ERROR_SUCCESS, "set string failed\n");
860 sz = sizeof buffer;
861 r = MsiFormatRecord(0, hrec, buffer, &sz);
862 ok( r == ERROR_SUCCESS, "format failed\n");
863 ok( sz == 11, "size wrong\n");
864 ok( 0 == strcmp(buffer,"boo [~] hoo"), "wrong output (%s)\n",buffer);
866 r = MsiRecordSetString(hrec, 0, "[1]");
867 r = MsiRecordSetInteger(hrec, 1, 123456);
868 ok( r == ERROR_SUCCESS, "set integer failed\n");
869 sz = sizeof buffer;
870 r = MsiFormatRecord(0, hrec, buffer, &sz);
871 ok( r == ERROR_SUCCESS, "format failed\n");
872 ok( sz == 6, "size wrong\n");
873 ok( 0 == strcmp(buffer,"123456"), "wrong output (%s)\n",buffer);
875 r = MsiRecordSetString(hrec, 0, "[~]");
876 sz = sizeof buffer;
877 r = MsiFormatRecord(0, hrec, buffer, &sz);
878 ok( sz == 3, "size wrong\n");
879 ok( 0 == strcmp(buffer,"[~]"), "wrong output\n");
880 ok( r == ERROR_SUCCESS, "format failed\n");
882 r = MsiRecordSetString(hrec, 0, "[]");
883 sz = sizeof buffer;
884 r = MsiFormatRecord(0, hrec, buffer, &sz);
885 ok( sz == 2, "size wrong\n");
886 ok( 0 == strcmp(buffer,"[]"), "wrong output\n");
887 ok( r == ERROR_SUCCESS, "format failed\n");
889 /* MsiFormatRecord doesn't seem to handle a negative too well */
890 r = MsiRecordSetString(hrec, 0, "[-1]");
891 sz = sizeof buffer;
892 r = MsiFormatRecord(0, hrec, buffer, &sz);
893 ok( sz == 4, "size wrong\n");
894 ok( 0 == strcmp(buffer,"[-1]"), "wrong output\n");
895 ok( r == ERROR_SUCCESS, "format failed\n");
897 r = MsiRecordSetString(hrec, 0, "{[]}");
898 sz = sizeof buffer;
899 r = MsiFormatRecord(0, hrec, buffer, &sz);
900 ok( sz == 4, "size wrong\n");
901 ok( 0 == strcmp(buffer,"{[]}"), "wrong output\n");
902 ok( r == ERROR_SUCCESS, "format failed\n");
904 r = MsiRecordSetString(hrec, 0, "[0]");
905 sz = sizeof buffer;
906 r = MsiFormatRecord(0, hrec, buffer, &sz);
907 ok( sz == 3, "size wrong\n");
908 ok( 0 == strcmp(buffer,"[0]"), "wrong output\n");
909 ok( r == ERROR_SUCCESS, "format failed\n");
911 r = MsiRecordSetString(hrec, 0, "[100]");
912 sz = sizeof buffer;
913 r = MsiFormatRecord(0, hrec, buffer, &sz);
914 ok( sz == 0, "size wrong\n");
915 ok( 0 == strcmp(buffer,""), "wrong output\n");
916 ok( r == ERROR_SUCCESS, "format failed\n");
918 r = MsiRecordSetString(hrec, 0, "{[1] [2]}");
919 r = MsiRecordSetString(hrec, 1, "boo");
920 r = MsiRecordSetString(hrec, 2, "hoo");
921 sz = sizeof buffer;
922 r = MsiFormatRecord(0, hrec, buffer, &sz);
923 ok( sz == 7, "size wrong\n");
924 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
925 ok( r == ERROR_SUCCESS, "format failed\n");
927 r = MsiRecordSetString(hrec, 0, "{}");
928 sz = sizeof buffer;
929 r = MsiFormatRecord(0, hrec, buffer, &sz);
930 ok( sz == 0, "size wrong\n");
931 ok( 0 == strcmp(buffer,""), "wrong output\n");
932 ok( r == ERROR_SUCCESS, "format failed\n");
934 r = MsiRecordSetString(hrec, 0, "{foo}");
935 sz = sizeof buffer;
936 r = MsiFormatRecord(0, hrec, buffer, &sz);
937 ok( sz == 5, "size wrong\n");
938 ok( 0 == strcmp(buffer,"{foo}"), "wrong output\n");
939 ok( r == ERROR_SUCCESS, "format failed\n");
941 r = MsiRecordSetString(hrec, 0, "{boo [1]}");
942 r = MsiRecordSetString(hrec, 1, "hoo");
943 sz = sizeof buffer;
944 r = MsiFormatRecord(0, hrec, buffer, &sz);
945 ok( sz == 7, "size wrong\n");
946 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
947 ok( r == ERROR_SUCCESS, "format failed\n");
949 r = MsiRecordSetString(hrec, 0, "{{[1]}}");
950 r = MsiRecordSetString(hrec, 1, "hoo");
951 sz = sizeof buffer;
952 r = MsiFormatRecord(0, hrec, buffer, &sz);
953 ok( sz == 0, "size wrong\n");
954 ok( 0 == strcmp(buffer,""), "wrong output\n");
955 ok( r == ERROR_SUCCESS, "format failed\n");
957 r = MsiRecordSetString(hrec, 0, "{ {[1]}}");
958 r = MsiRecordSetString(hrec, 1, "hoo");
959 sz = sizeof buffer;
960 r = MsiFormatRecord(0, hrec, buffer, &sz);
961 todo_wine
963 ok( 0 == strcmp(buffer," {hoo}"), "wrong output\n");
964 ok( sz == 6, "size wrong\n");
966 ok( r == ERROR_SUCCESS, "format failed\n");
968 r = MsiRecordSetString(hrec, 0, "{{[1]} }");
969 r = MsiRecordSetString(hrec, 1, "hoo");
970 sz = sizeof buffer;
971 r = MsiFormatRecord(0, hrec, buffer, &sz);
972 ok( sz == 8, "size wrong\n");
973 ok( 0 == strcmp(buffer,"{{hoo} }"), "wrong output\n");
974 ok( r == ERROR_SUCCESS, "format failed\n");
976 r = MsiRecordSetString(hrec, 0, "{{ [1]}}");
977 r = MsiRecordSetString(hrec, 1, "hoo");
978 sz = sizeof buffer;
979 r = MsiFormatRecord(0, hrec, buffer, &sz);
980 ok( sz == 0, "size wrong\n");
981 ok( 0 == strcmp(buffer,""), "wrong output\n");
982 ok( r == ERROR_SUCCESS, "format failed\n");
984 r = MsiRecordSetString(hrec, 0, "{{[1] }}");
985 r = MsiRecordSetString(hrec, 1, "hoo");
986 sz = sizeof buffer;
987 r = MsiFormatRecord(0, hrec, buffer, &sz);
988 ok( sz == 0, "size wrong\n");
989 ok( 0 == strcmp(buffer,""), "wrong output\n");
990 ok( r == ERROR_SUCCESS, "format failed\n");
992 r = MsiRecordSetString(hrec, 0, "{{a}{b}{c }{ d}{any text}}");
993 sz = sizeof buffer;
994 r = MsiFormatRecord(0, hrec, buffer, &sz);
995 ok( sz == 0, "size wrong\n");
996 ok( 0 == strcmp(buffer,""), "wrong output\n");
997 ok( r == ERROR_SUCCESS, "format failed\n");
999 r = MsiRecordSetString(hrec, 0, "{{a} }");
1000 sz = sizeof buffer;
1001 r = MsiFormatRecord(0, hrec, buffer, &sz);
1002 ok( sz == 6, "size wrong\n");
1003 ok( 0 == strcmp(buffer,"{{a} }"), "wrong output\n");
1004 ok( r == ERROR_SUCCESS, "format failed\n");
1006 r = MsiRecordSetString(hrec, 0, "{{a} {b}}");
1007 sz = sizeof buffer;
1008 r = MsiFormatRecord(0, hrec, buffer, &sz);
1009 ok( sz == 0, "size wrong\n");
1010 ok( 0 == strcmp(buffer,""), "wrong output\n");
1011 ok( r == ERROR_SUCCESS, "format failed\n");
1013 todo_wine {
1014 r = MsiRecordSetString(hrec, 0, "{{a} b}}");
1015 sz = sizeof buffer;
1016 r = MsiFormatRecord(0, hrec, buffer, &sz);
1017 ok( sz == 0, "size wrong\n");
1018 ok( 0 == strcmp(buffer,""), "wrong output\n");
1020 ok( r == ERROR_SUCCESS, "format failed\n");
1022 r = MsiRecordSetString(hrec, 0, "{{a b}}");
1023 sz = sizeof buffer;
1024 r = MsiFormatRecord(0, hrec, buffer, &sz);
1025 ok( sz == 0, "size wrong\n");
1026 ok( 0 == strcmp(buffer,""), "wrong output\n");
1027 ok( r == ERROR_SUCCESS, "format failed\n");
1029 r = MsiRecordSetString(hrec, 0, "{ }");
1030 sz = sizeof buffer;
1031 r = MsiFormatRecord(0, hrec, buffer, &sz);
1032 ok( sz == 3, "size wrong\n");
1033 ok( 0 == strcmp(buffer,"{ }"), "wrong output\n");
1034 ok( r == ERROR_SUCCESS, "format failed\n");
1036 r = MsiRecordSetString(hrec, 0, " {{a}}}");
1037 sz = sizeof buffer;
1038 r = MsiFormatRecord(0, hrec, buffer, &sz);
1039 ok( sz == 2, "size wrong\n");
1040 ok( 0 == strcmp(buffer," }"), "wrong output\n");
1041 ok( r == ERROR_SUCCESS, "format failed\n");
1043 todo_wine {
1044 r = MsiRecordSetString(hrec, 0, "{{ almost {{ any }} text }}");
1045 sz = sizeof buffer;
1046 r = MsiFormatRecord(0, hrec, buffer, &sz);
1047 ok( sz == 8, "size wrong\n");
1048 ok( 0 == strcmp(buffer," text }}"), "wrong output\n");
1050 ok( r == ERROR_SUCCESS, "format failed\n");
1052 todo_wine {
1053 r = MsiRecordSetString(hrec, 0, "{{ } { hidden ][ [ }}");
1054 sz = sizeof buffer;
1055 r = MsiFormatRecord(0, hrec, buffer, &sz);
1056 ok( sz == 0, "size wrong\n");
1057 ok( 0 == strcmp(buffer,""), "wrong output\n");
1059 ok( r == ERROR_SUCCESS, "format failed\n");
1061 r = MsiRecordSetString(hrec, 0, "[ 1]");
1062 r = MsiRecordSetString(hrec, 1, "hoo");
1063 sz = sizeof buffer;
1064 r = MsiFormatRecord(0, hrec, buffer, &sz);
1065 ok( sz == 4, "size wrong\n");
1066 ok( 0 == strcmp(buffer,"[ 1]"), "wrong output\n");
1067 ok( r == ERROR_SUCCESS, "format failed\n");
1069 r = MsiRecordSetString(hrec, 0, "[01]");
1070 r = MsiRecordSetString(hrec, 1, "hoo");
1071 sz = sizeof buffer;
1072 r = MsiFormatRecord(0, hrec, buffer, &sz);
1073 ok( sz == 3, "size wrong\n");
1074 ok( 0 == strcmp(buffer,"hoo"), "wrong output\n");
1075 ok( r == ERROR_SUCCESS, "format failed\n");
1077 todo_wine {
1078 r = MsiRecordSetString(hrec, 0, "{{test}} [01");
1079 r = MsiRecordSetString(hrec, 1, "hoo");
1080 sz = sizeof buffer;
1081 r = MsiFormatRecord(0, hrec, buffer, &sz);
1082 ok( sz == 4, "size wrong\n");
1083 ok( 0 == strcmp(buffer," [01"), "wrong output\n");
1085 ok( r == ERROR_SUCCESS, "format failed\n");
1087 r = MsiRecordSetString(hrec, 0, "[\\[]");
1088 r = MsiRecordSetString(hrec, 1, "hoo");
1089 sz = sizeof buffer;
1090 r = MsiFormatRecord(0, hrec, buffer, &sz);
1091 ok( sz == 4, "size wrong\n");
1092 ok( 0 == strcmp(buffer,"[\\[]"), "wrong output\n");
1093 ok( r == ERROR_SUCCESS, "format failed\n");
1095 MsiRecordSetString(hrec, 0, "[\\[]");
1096 MsiRecordSetString(hrec, 1, "hoo");
1097 sz = sizeof(buffer);
1098 r = MsiFormatRecord(0, hrec, buffer, &sz);
1099 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1100 ok(sz == 4, "Expected 4, got %d\n", sz);
1101 ok(!lstrcmpA(buffer, "[\\[]"), "Expected \"[\\[]\", got \"%s\"\n", buffer);
1103 r = MsiRecordSetString(hrec, 0, "[foo]");
1104 r = MsiRecordSetString(hrec, 1, "hoo");
1105 sz = sizeof buffer;
1106 r = MsiFormatRecord(0, hrec, buffer, &sz);
1107 ok( sz == 5, "size wrong\n");
1108 ok( 0 == strcmp(buffer,"[foo]"), "wrong output\n");
1109 ok( r == ERROR_SUCCESS, "format failed\n");
1111 r = MsiRecordSetString(hrec, 0, "[01.]");
1112 r = MsiRecordSetString(hrec, 1, "hoo");
1113 sz = sizeof buffer;
1114 r = MsiFormatRecord(0, hrec, buffer, &sz);
1115 ok( sz == 5, "size wrong\n");
1116 ok( 0 == strcmp(buffer,"[01.]"), "wrong output\n");
1117 ok( r == ERROR_SUCCESS, "format failed\n");
1119 SetEnvironmentVariable("FOO", "BAR");
1120 r = MsiRecordSetString(hrec, 0, "[%FOO]");
1121 sz = sizeof buffer;
1122 r = MsiFormatRecord(0, hrec, buffer, &sz);
1123 ok( sz == 6, "size wrong\n");
1124 ok( 0 == strcmp(buffer,"[%FOO]"), "wrong output\n");
1125 ok( r == ERROR_SUCCESS, "format failed\n");
1127 r = MsiRecordSetString(hrec, 0, "{{[1]}");
1128 r = MsiRecordSetString(hrec, 1, "hoo");
1129 sz = sizeof buffer;
1130 r = MsiFormatRecord(0, hrec, buffer, &sz);
1131 ok( sz == 6, "size wrong\n");
1132 ok( 0 == strcmp(buffer,"{{hoo}"), "wrong output\n");
1133 ok( r == ERROR_SUCCESS, "format failed\n");
1135 r = MsiRecordSetString(hrec, 0, "{{ {[1]}");
1136 r = MsiRecordSetString(hrec, 1, "hoo");
1137 sz = sizeof buffer;
1138 r = MsiFormatRecord(0, hrec, buffer, &sz);
1139 ok( sz == 8, "size wrong\n");
1140 ok( 0 == strcmp(buffer,"{{ {hoo}"), "wrong output\n");
1141 ok( r == ERROR_SUCCESS, "format failed\n");
1143 r = MsiRecordSetString(hrec, 0, "{{ {[1]}");
1144 r = MsiRecordSetString(hrec, 1, "hoo");
1145 sz = sizeof buffer;
1146 r = MsiFormatRecord(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");
1151 r = MsiRecordSetString(hrec, 0, "{{ {{[1]}");
1152 r = MsiRecordSetString(hrec, 1, "hoo");
1153 sz = sizeof buffer;
1154 r = MsiFormatRecord(0, hrec, buffer, &sz);
1155 ok( sz == 9, "size wrong\n");
1156 ok( 0 == strcmp(buffer,"{{ {{hoo}"), "wrong output\n");
1157 ok( r == ERROR_SUCCESS, "format failed\n");
1159 r = MsiRecordSetString(hrec, 0, "[1]}");
1160 r = MsiRecordSetString(hrec, 1, "hoo");
1161 sz = sizeof buffer;
1162 r = MsiFormatRecord(0, hrec, buffer, &sz);
1163 ok( sz == 4, "size wrong\n");
1164 ok( 0 == strcmp(buffer,"hoo}"), "wrong output\n");
1165 ok( r == ERROR_SUCCESS, "format failed\n");
1167 r = MsiRecordSetString(hrec, 0, "{{ {{a}");
1168 sz = sizeof buffer;
1169 r = MsiFormatRecord(0, hrec, buffer, &sz);
1170 ok( sz == 7, "size wrong\n");
1171 ok( 0 == strcmp(buffer,"{{ {{a}"), "wrong output\n");
1172 ok( r == ERROR_SUCCESS, "format failed\n");
1174 r = MsiRecordSetString(hrec, 0, "{{ {{a}");
1175 sz = sizeof buffer;
1176 r = MsiFormatRecord(0, hrec, buffer, &sz);
1177 ok( sz == 7, "size wrong\n");
1178 ok( 0 == strcmp(buffer,"{{ {{a}"), "wrong output\n");
1179 ok( r == ERROR_SUCCESS, "format failed\n");
1181 r = MsiRecordSetString(hrec, 0, "0{1{2{3{4[1]5}6}7}8}9");
1182 r = MsiRecordSetString(hrec, 1, "hoo");
1183 sz = sizeof buffer;
1184 r = MsiFormatRecord(0, hrec, buffer, &sz);
1185 todo_wine
1187 ok( sz == 19, "size wrong\n");
1188 ok( 0 == strcmp(buffer,"01{2{3{4hoo56}7}8}9"), "wrong output\n");
1190 ok( r == ERROR_SUCCESS, "format failed\n");
1192 r = MsiRecordSetString(hrec, 0, "0{1{2[1]3}4");
1193 r = MsiRecordSetString(hrec, 1, "hoo");
1194 sz = sizeof buffer;
1195 r = MsiFormatRecord(0, hrec, buffer, &sz);
1196 todo_wine
1198 ok( sz == 9, "size wrong\n");
1199 ok( 0 == strcmp(buffer,"01{2hoo34"), "wrong output\n");
1201 ok( r == ERROR_SUCCESS, "format failed\n");
1203 r = MsiRecordSetString(hrec, 0, "0{1{2[1]3}4");
1204 r = MsiRecordSetString(hrec, 1, "hoo");
1205 sz = sizeof buffer;
1206 r = MsiFormatRecord(0, hrec, buffer, &sz);
1207 todo_wine
1209 ok( sz == 9, "size wrong\n");
1210 ok( 0 == strcmp(buffer,"01{2hoo34"), "wrong output\n");
1212 ok( r == ERROR_SUCCESS, "format failed\n");
1214 r = MsiRecordSetString(hrec, 0, "{[1.} [1]");
1215 r = MsiRecordSetString(hrec, 1, "hoo");
1216 sz = sizeof buffer;
1217 r = MsiFormatRecord(0, hrec, buffer, &sz);
1218 ok( sz == 9, "size wrong\n");
1219 todo_wine
1221 ok( 0 == strcmp(buffer,"{[1.} hoo"), "wrong output\n");
1223 ok( r == ERROR_SUCCESS, "format failed\n");
1225 r = MsiRecordSetString(hrec, 0, "{[{[1]}]}");
1226 r = MsiRecordSetString(hrec, 1, "2");
1227 r = MsiRecordSetString(hrec, 2, "foo");
1228 sz = sizeof buffer;
1229 r = MsiFormatRecord(0, hrec, buffer, &sz);
1230 todo_wine
1232 ok( sz == 9, "size wrong\n");
1233 ok( 0 == strcmp(buffer,"{[{[1]}]}"), "wrong output\n");
1235 ok( r == ERROR_SUCCESS, "format failed\n");
1237 r = MsiRecordSetString(hrec, 0, "{[1][}");
1238 r = MsiRecordSetString(hrec, 1, "2");
1239 r = MsiRecordSetString(hrec, 2, "foo");
1240 sz = sizeof buffer;
1241 r = MsiFormatRecord(0, hrec, buffer, &sz);
1242 todo_wine
1244 ok( sz == 2, "size wrong\n");
1245 ok( 0 == strcmp(buffer,"2["), "wrong output\n");
1247 ok( r == ERROR_SUCCESS, "format failed\n");
1249 r = MsiRecordSetString(hrec, 0, "[1]");
1250 r = MsiRecordSetString(hrec, 1, "[2]");
1251 r = MsiRecordSetString(hrec, 2, "foo");
1252 sz = sizeof buffer;
1253 r = MsiFormatRecord(0, hrec, buffer, &sz);
1254 ok( sz == 3, "size wrong\n");
1255 ok( 0 == strcmp(buffer,"[2]"), "wrong output\n");
1256 ok( r == ERROR_SUCCESS, "format failed\n");
1258 r = MsiRecordSetString(hrec, 0, "[{{boo}}1]");
1259 r = MsiRecordSetString(hrec, 1, "hoo");
1260 sz = sizeof buffer;
1261 r = MsiFormatRecord(0, hrec, buffer, &sz);
1262 ok( r == ERROR_SUCCESS, "format failed\n");
1263 ok( sz == 3, "size wrong\n");
1264 todo_wine
1266 ok( 0 == strcmp(buffer,"[1]"), "wrong output: %s\n", buffer);
1269 r = MsiRecordSetString(hrec, 0, "[{{boo}}1]");
1270 r = MsiRecordSetString(hrec, 0, "[1{{boo}}]");
1271 r = MsiRecordSetString(hrec, 1, "hoo");
1272 sz = sizeof buffer;
1273 r = MsiFormatRecord(0, hrec, buffer, &sz);
1274 ok( sz == 3, "size wrong\n");
1275 ok( 0 == strcmp(buffer,"[1]"), "wrong output\n");
1276 ok( r == ERROR_SUCCESS, "format failed\n");
1278 r = MsiRecordSetString(hrec, 0, "{[1]{{boo} }}");
1279 r = MsiRecordSetString(hrec, 1, "hoo");
1280 sz = sizeof buffer;
1281 r = MsiFormatRecord(0, hrec, buffer, &sz);
1282 todo_wine
1284 ok( sz == 11, "size wrong\n");
1285 ok( 0 == strcmp(buffer,"hoo{{boo }}"), "wrong output\n");
1287 ok( r == ERROR_SUCCESS, "format failed\n");
1289 r = MsiRecordSetString(hrec, 0, "{[1{{boo}}]}");
1290 r = MsiRecordSetString(hrec, 1, "hoo");
1291 sz = sizeof buffer;
1292 r = MsiFormatRecord(0, hrec, buffer, &sz);
1293 todo_wine
1295 ok( sz == 12, "size wrong: got %u, expected 12\n", sz);
1296 ok( 0 == strcmp(buffer,"{[1{{boo}}]}"), "wrong output: got %s, expected [1]\n", buffer);
1298 ok( r == ERROR_SUCCESS, "format failed\n");
1300 r = MsiRecordSetString(hrec, 0, "{{[1]}");
1301 r = MsiRecordSetString(hrec, 1, "hoo");
1302 sz = sizeof buffer;
1303 r = MsiFormatRecord(0, hrec, buffer, &sz);
1304 ok( sz == 6, "size wrong: got %u, expected 3\n", sz);
1305 ok( 0 == strcmp(buffer,"{{hoo}"), "wrong output: got %s, expected [1]\n", buffer);
1306 ok( r == ERROR_SUCCESS, "format failed\n");
1308 r = MsiRecordSetString(hrec, 0, "{[1{{bo}o}}]}");
1309 r = MsiRecordSetString(hrec, 1, "hoo");
1310 sz = sizeof buffer;
1311 r = MsiFormatRecord(0, hrec, buffer, &sz);
1312 ok( sz == 13, "size wrong\n");
1313 ok( 0 == strcmp(buffer,"{[1{{bo}o}}]}"), "wrong output %s\n",buffer);
1314 ok( r == ERROR_SUCCESS, "format failed\n");
1316 r = MsiRecordSetString(hrec, 0, "{[1{{b{o}o}}]}");
1317 sz = sizeof buffer;
1318 r = MsiFormatRecord(0, hrec, buffer, &sz);
1319 todo_wine
1321 ok( sz == 14, "size wrong\n");
1322 ok( 0 == strcmp(buffer,"{[1{{b{o}o}}]}"), "wrong output %s\n",buffer);
1324 ok( r == ERROR_SUCCESS, "format failed\n");
1326 r = MsiRecordSetString(hrec, 0, "{ {[1]}");
1327 r = MsiRecordSetString(hrec, 1, "hoo");
1328 sz = sizeof buffer;
1329 r = MsiFormatRecord(0, hrec, buffer, &sz);
1330 todo_wine
1332 ok( sz == 5, "size wrong\n");
1333 ok( 0 == strcmp(buffer," {hoo"), "wrong output %s\n",buffer);
1335 ok( r == ERROR_SUCCESS, "format failed\n");
1337 /* {} inside a substitution does strange things... */
1338 r = MsiRecordSetString(hrec, 0, "[[1]{}]");
1339 r = MsiRecordSetString(hrec, 1, "2");
1340 sz = sizeof buffer;
1341 r = MsiFormatRecord(0, hrec, buffer, &sz);
1342 todo_wine
1344 ok( sz == 5, "size wrong\n");
1345 ok( 0 == strcmp(buffer,"[[1]]"), "wrong output %s\n",buffer);
1347 ok( r == ERROR_SUCCESS, "format failed\n");
1349 r = MsiRecordSetString(hrec, 0, "[[1]{}[1]]");
1350 r = MsiRecordSetString(hrec, 1, "2");
1351 sz = sizeof buffer;
1352 r = MsiFormatRecord(0, hrec, buffer, &sz);
1353 todo_wine
1355 ok( sz == 6, "size wrong\n");
1356 ok( 0 == strcmp(buffer,"[[1]2]"), "wrong output %s\n",buffer);
1358 ok( r == ERROR_SUCCESS, "format failed\n");
1360 r = MsiRecordSetString(hrec, 0, "[a[1]b[1]c{}d[1]e]");
1361 r = MsiRecordSetString(hrec, 1, "2");
1362 sz = sizeof buffer;
1363 r = MsiFormatRecord(0, hrec, buffer, &sz);
1364 todo_wine
1366 ok( sz == 14, "size wrong\n");
1367 ok( 0 == strcmp(buffer,"[a[1]b[1]cd2e]"), "wrong output %s\n",buffer);
1369 ok( r == ERROR_SUCCESS, "format failed\n");
1371 r = MsiRecordSetString(hrec, 0, "[a[1]b");
1372 r = MsiRecordSetString(hrec, 1, "2");
1373 sz = sizeof buffer;
1374 r = MsiFormatRecord(0, hrec, buffer, &sz);
1375 ok( sz == 6, "size wrong\n");
1376 ok( 0 == strcmp(buffer,"[a[1]b"), "wrong output %s\n",buffer);
1377 ok( r == ERROR_SUCCESS, "format failed\n");
1379 r = MsiRecordSetString(hrec, 0, "a[1]b]");
1380 r = MsiRecordSetString(hrec, 1, "2");
1381 sz = sizeof buffer;
1382 r = MsiFormatRecord(0, hrec, buffer, &sz);
1383 ok( sz == 4, "size wrong\n");
1384 ok( 0 == strcmp(buffer,"a2b]"), "wrong output %s\n",buffer);
1385 ok( r == ERROR_SUCCESS, "format failed\n");
1387 r = MsiRecordSetString(hrec, 0, "]a[1]b");
1388 r = MsiRecordSetString(hrec, 1, "2");
1389 sz = sizeof buffer;
1390 r = MsiFormatRecord(0, hrec, buffer, &sz);
1391 ok( sz == 4, "size wrong\n");
1392 ok( 0 == strcmp(buffer,"]a2b"), "wrong output %s\n",buffer);
1393 ok( r == ERROR_SUCCESS, "format failed\n");
1395 r = MsiRecordSetString(hrec, 0, "]a[1]b");
1396 r = MsiRecordSetString(hrec, 1, "2");
1397 sz = sizeof buffer;
1398 r = MsiFormatRecord(0, hrec, buffer, &sz);
1399 ok( sz == 4, "size wrong\n");
1400 ok( 0 == strcmp(buffer,"]a2b"), "wrong output %s\n",buffer);
1401 ok( r == ERROR_SUCCESS, "format failed\n");
1403 r = MsiRecordSetString(hrec, 0, "\\[1]");
1404 r = MsiRecordSetString(hrec, 1, "2");
1405 sz = sizeof buffer;
1406 r = MsiFormatRecord(0, hrec, buffer, &sz);
1407 ok( sz == 2, "size wrong\n");
1408 ok( 0 == strcmp(buffer,"\\2"), "wrong output %s\n",buffer);
1409 ok( r == ERROR_SUCCESS, "format failed\n");
1411 r = MsiRecordSetString(hrec, 0, "\\{[1]}");
1412 r = MsiRecordSetString(hrec, 1, "2");
1413 sz = sizeof buffer;
1414 r = MsiFormatRecord(0, hrec, buffer, &sz);
1415 ok( sz == 2, "size wrong\n");
1416 ok( 0 == strcmp(buffer,"\\2"), "wrong output %s\n",buffer);
1417 ok( r == ERROR_SUCCESS, "format failed\n");
1419 r = MsiRecordSetString(hrec, 0, "a{b[1]c}d");
1420 r = MsiRecordSetString(hrec, 1, NULL);
1421 sz = sizeof buffer;
1422 r = MsiFormatRecord(0, hrec, buffer, &sz);
1423 ok( sz == 2, "size wrong\n");
1424 ok( 0 == strcmp(buffer,"ad"), "wrong output %s\n",buffer);
1425 ok( r == ERROR_SUCCESS, "format failed\n");
1427 r = MsiRecordSetString(hrec, 0, "{a[0]b}");
1428 r = MsiRecordSetString(hrec, 1, "foo");
1429 sz = sizeof buffer;
1430 r = MsiFormatRecord(0, hrec, buffer, &sz);
1431 ok( sz == 9, "size wrong\n");
1432 ok( 0 == strcmp(buffer,"a{a[0]b}b"), "wrong output %s\n",buffer);
1433 ok( r == ERROR_SUCCESS, "format failed\n");
1435 r = MsiRecordSetString(hrec, 0, "[foo]");
1436 sz = sizeof buffer;
1437 r = MsiFormatRecord(0, hrec, buffer, &sz);
1438 ok( sz == 5, "size wrong\n");
1439 ok( 0 == strcmp(buffer,"[foo]"), "wrong output %s\n",buffer);
1440 ok( r == ERROR_SUCCESS, "format failed\n");
1442 r = MsiRecordSetString(hrec, 0, "{[1][-1][1]}");
1443 r = MsiRecordSetString(hrec, 1, "foo");
1444 sz = sizeof buffer;
1445 r = MsiFormatRecord(0, hrec, buffer, &sz);
1446 todo_wine
1448 ok( sz == 12, "size wrong\n");
1449 ok( 0 == strcmp(buffer,"{foo[-1]foo}"), "wrong output %s\n",buffer);
1451 ok( r == ERROR_SUCCESS, "format failed\n");
1453 /* nested braces */
1454 sz = sizeof buffer;
1455 MsiRecordSetString(hrec, 0, "{abcd}");
1456 r = MsiFormatRecord(0, hrec, buffer, &sz);
1457 ok( r == ERROR_SUCCESS, "format failed\n");
1458 ok( sz == 6, "size wrong(%i)\n",sz);
1459 ok( 0 == strcmp(buffer,"{abcd}"), "wrong output (%s)\n",buffer);
1461 sz = sizeof buffer;
1462 MsiRecordSetString(hrec, 0, "{a[one]bc[two]de[one]f}");
1463 r = MsiFormatRecord(0, hrec, buffer, &sz);
1464 ok( r == ERROR_SUCCESS, "format failed\n");
1465 ok( sz == 23, "size wrong(%i)\n",sz);
1466 ok( 0 == strcmp(buffer,"{a[one]bc[two]de[one]f}"), "wrong output (%s)\n",buffer);
1468 sz = sizeof buffer;
1469 MsiRecordSetString(hrec, 0, "{a[one]bc[bad]de[two]f}");
1470 r = MsiFormatRecord(0, hrec, buffer, &sz);
1471 ok( r == ERROR_SUCCESS, "format failed\n");
1472 ok( sz == 23, "size wrong(%i)\n",sz);
1473 ok( 0 == strcmp(buffer,"{a[one]bc[bad]de[two]f}"), "wrong output (%s)\n",buffer);
1475 sz = sizeof buffer;
1476 MsiRecordSetString(hrec, 0, "{[bad]}");
1477 r = MsiFormatRecord(0, hrec, buffer, &sz);
1478 ok( r == ERROR_SUCCESS, "format failed\n");
1479 ok( sz == 7, "size wrong(%i)\n",sz);
1480 ok( 0 == strcmp(buffer,"{[bad]}"), "wrong output (%s)\n",buffer);
1482 sz = sizeof buffer;
1483 MsiRecordSetString(hrec, 0, "{abc{d[one]ef}"); /* missing final brace */
1484 r = MsiFormatRecord(0, hrec, buffer, &sz);
1485 ok( r == ERROR_SUCCESS, "format failed\n");
1486 ok( sz == 14, "size wrong(%i)\n",sz);
1487 ok( 0 == strcmp(buffer,"{abc{d[one]ef}"), "wrong output (%s)\n",buffer);
1489 sz = sizeof buffer;
1490 MsiRecordSetString(hrec, 0, "{abc{d[one]ef}}");
1491 r = MsiFormatRecord(0, hrec, buffer, &sz);
1492 ok( r == ERROR_SUCCESS, "format failed\n");
1493 ok( sz == 15, "size wrong(%i)\n",sz);
1494 ok( 0 == strcmp(buffer,"{abc{d[one]ef}}"), "wrong output (%s)\n",buffer);
1496 sz = sizeof buffer;
1497 MsiRecordSetString(hrec, 0, "{abc}{{def}hi{j[one]k}}");
1498 r = MsiFormatRecord(0, hrec, buffer, &sz);
1499 ok( r == ERROR_SUCCESS, "format failed\n");
1500 ok( sz == 5, "size wrong(%i)\n",sz);
1501 ok( 0 == strcmp(buffer,"{abc}"), "wrong output (%s)\n",buffer);
1503 sz = sizeof buffer;
1504 MsiRecordSetString(hrec, 0, "{{def}hi{j[one]k}}");
1505 r = MsiFormatRecord(0, hrec, buffer, &sz);
1506 ok( r == ERROR_SUCCESS, "format failed\n");
1507 ok( sz == 0, "size wrong(%i)\n",sz);
1508 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
1510 sz = sizeof buffer;
1511 MsiRecordSetString(hrec, 0, "{{def}hi{jk}}");
1512 r = MsiFormatRecord(0, hrec, buffer, &sz);
1513 ok( r == ERROR_SUCCESS, "format failed\n");
1514 ok( sz == 0, "size wrong(%i)\n",sz);
1515 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
1517 sz = sizeof buffer;
1518 MsiRecordSetString(hrec, 0, "{{{def}}hi{jk}}");
1519 r = MsiFormatRecord(0, hrec, buffer, &sz);
1520 ok( r == ERROR_SUCCESS, "format failed\n");
1521 todo_wine
1523 ok( sz == 7, "size wrong(%i)\n",sz);
1524 ok( 0 == strcmp(buffer,"hi{jk}}"), "wrong output (%s)\n",buffer);
1527 sz = sizeof buffer;
1528 MsiRecordSetString(hrec, 0, "{{def}hi{{jk}}}");
1529 r = MsiFormatRecord(0, hrec, buffer, &sz);
1530 ok( r == ERROR_SUCCESS, "format failed\n");
1531 todo_wine
1533 ok( sz == 1, "size wrong(%i)\n",sz);
1534 ok( 0 == strcmp(buffer,"}"), "wrong output (%s)\n",buffer);
1537 sz = sizeof buffer;
1538 MsiRecordSetString(hrec, 0, "{{def}{jk}}");
1539 r = MsiFormatRecord(0, hrec, buffer, &sz);
1540 ok( r == ERROR_SUCCESS, "format failed\n");
1541 ok( sz == 0, "size wrong(%i)\n",sz);
1542 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
1544 sz = sizeof buffer;
1545 MsiRecordSetString(hrec, 0, "{{def}}");
1546 r = MsiFormatRecord(0, hrec, buffer, &sz);
1547 ok( r == ERROR_SUCCESS, "format failed\n");
1548 ok( sz == 0, "size wrong(%i)\n",sz);
1549 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
1551 sz = sizeof buffer;
1552 MsiRecordSetString(hrec, 0, "{a{b}c}");
1553 r = MsiFormatRecord(0, hrec, buffer, &sz);
1554 ok( r == ERROR_SUCCESS, "format failed\n");
1555 ok( sz == 7, "size wrong(%i)\n",sz);
1556 ok( 0 == strcmp(buffer,"{a{b}c}"), "wrong output (%s)\n",buffer);
1558 sz = sizeof buffer;
1559 MsiRecordSetString(hrec, 0, "{a{b}}");
1560 r = MsiFormatRecord(0, hrec, buffer, &sz);
1561 ok( r == ERROR_SUCCESS, "format failed\n");
1562 ok( sz == 6, "size wrong(%i)\n",sz);
1563 ok( 0 == strcmp(buffer,"{a{b}}"), "wrong output (%s)\n",buffer);
1565 sz = sizeof buffer;
1566 MsiRecordSetString(hrec, 0, "{{b}c}");
1567 r = MsiFormatRecord(0, hrec, buffer, &sz);
1568 ok( r == ERROR_SUCCESS, "format failed\n");
1569 ok( sz == 6, "size wrong(%i)\n",sz);
1570 ok( 0 == strcmp(buffer,"{{b}c}"), "wrong output (%s)\n",buffer);
1572 sz = sizeof buffer;
1573 MsiRecordSetString(hrec, 0, "{{{{}}}}");
1574 r = MsiFormatRecord(0, hrec, buffer, &sz);
1575 ok( r == ERROR_SUCCESS, "format failed\n");
1576 todo_wine
1578 ok( sz == 2, "size wrong(%i)\n",sz);
1579 ok( 0 == strcmp(buffer,"}}"), "wrong output (%s)\n",buffer);
1582 sz = sizeof buffer;
1583 MsiRecordSetInteger(hrec, 1, 100);
1584 MsiRecordSetInteger(hrec, 2, -100);
1585 MsiRecordSetString(hrec, 0, "[1] [2]");
1586 r = MsiFormatRecord(0, hrec, buffer, &sz);
1587 ok( r == ERROR_SUCCESS, "format failed\n");
1588 ok( sz == 8, "size wrong(%i)\n",sz);
1589 ok( 0 == strcmp(buffer,"100 -100"), "wrong output (%s)\n",buffer);
1591 sz = sizeof(buffer);
1592 MsiRecordSetString(hrec, 0, "[1] {[noprop] [twoprop]} {abcdef}");
1593 MsiRecordSetString(hrec, 1, "one");
1594 r = MsiFormatRecord(0, hrec, buffer, &sz);
1595 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1596 ok(sz == 33, "Expected 33, got %d\n",sz);
1597 ok(!lstrcmpA(buffer, "one {[noprop] [twoprop]} {abcdef}"),
1598 "Expected \"one {[noprop] [twoprop]} {abcdef}\", got \"%s\"\n", buffer);
1600 sz = sizeof(buffer);
1601 MsiRecordSetString(hrec, 0, "[1] {[noprop] [one]} {abcdef}");
1602 MsiRecordSetString(hrec, 1, "one");
1603 r = MsiFormatRecord(0, hrec, buffer, &sz);
1604 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1605 ok(sz == 29, "Expected 29, got %d\n",sz);
1606 ok(!lstrcmpA(buffer, "one {[noprop] [one]} {abcdef}"),
1607 "Expected \"one {[noprop] [one]} {abcdef}\", got \"%s\"\n", buffer);
1609 sz = sizeof(buffer);
1610 MsiRecordSetString(hrec, 0, "[1] {[one]} {abcdef}");
1611 MsiRecordSetString(hrec, 1, "one");
1612 r = MsiFormatRecord(0, hrec, buffer, &sz);
1613 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1614 ok(sz == 20, "Expected 20, got %d\n",sz);
1615 ok(!lstrcmpA(buffer, "one {[one]} {abcdef}"),
1616 "Expected \"one {[one]} {abcdef}\", got \"%s\"\n", buffer);
1618 MsiCloseHandle( hrec );
1621 static void test_formatrecord_package(void)
1623 static const CHAR filename[] = "winetest.msi";
1624 char buffer[100];
1625 MSIHANDLE hrec;
1626 MSIHANDLE package;
1627 UINT r;
1628 DWORD sz=100;
1630 package = helper_createpackage( filename );
1631 ok(package!=0, "Unable to create package\n");
1633 hrec = MsiCreateRecord(12);
1634 ok( hrec, "failed to create record\n");
1636 r = MsiFormatRecord(package, 0, NULL, NULL );
1637 ok( r == ERROR_INVALID_HANDLE, "wrong error\n");
1639 r = MsiFormatRecord(package, hrec, NULL, NULL );
1640 ok( r == ERROR_SUCCESS, "format failed\n");
1642 r = MsiRecordSetString(hrec,0,NULL);
1643 r = MsiRecordSetString(hrec,1,NULL);
1644 r = MsiRecordSetString(hrec,2,NULL);
1645 r = MsiRecordSetString(hrec,3,NULL);
1646 r = MsiRecordSetString(hrec,4,NULL);
1647 r = MsiRecordSetString(hrec,5,NULL);
1648 r = MsiRecordSetString(hrec,6,NULL);
1649 r = MsiRecordSetString(hrec,7,NULL);
1650 r = MsiRecordSetString(hrec,8,NULL);
1651 r = MsiRecordSetString(hrec,9,NULL);
1652 r = MsiRecordSetString(hrec,10,NULL);
1653 r = MsiRecordSetString(hrec,11,NULL);
1654 r = MsiRecordSetString(hrec,12,NULL);
1655 ok( r == ERROR_SUCCESS, "set string failed\n");
1657 sz = sizeof buffer;
1658 r = MsiFormatRecord(package, hrec, buffer, &sz);
1659 ok( r == ERROR_SUCCESS, "format failed with empty buffer (%i)\n",r);
1660 ok( sz == 51, "size wrong (%i)\n",sz);
1661 ok( 0 == strcmp(buffer,"1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: "), "wrong output(%s)\n",buffer);
1663 r = MsiSetProperty(package, "prop", "val");
1664 ok( r == ERROR_SUCCESS, "failed to set propertY: %d\n", r);
1666 r = MsiRecordSetString(hrec, 0, NULL);
1667 r = MsiRecordSetString(hrec, 1, "[2]");
1668 r = MsiRecordSetString(hrec, 2, "stuff");
1669 r = MsiRecordSetString(hrec, 3, "prop");
1670 r = MsiRecordSetString(hrec, 4, "[prop]");
1671 r = MsiRecordSetString(hrec, 5, "[noprop]");
1672 sz = sizeof buffer;
1673 r = MsiFormatRecord(package, hrec, buffer, &sz);
1674 ok( r == ERROR_SUCCESS, "format failed with empty buffer (%i)\n",r);
1675 todo_wine
1677 ok( sz == 66, "size wrong (%i)\n",sz);
1678 ok( !lstrcmpA(buffer,
1679 "1: [2] 2: stuff 3: prop 4: val 5: 6: 7: 8: 9: 10: 11: 12: "),
1680 "wrong output(%s)\n",buffer);
1683 /* now put play games with escaping */
1684 r = MsiRecordSetString(hrec, 0, "[1] [2] [\\3asdf]");
1685 r = MsiRecordSetString(hrec, 1, "boo");
1686 r = MsiRecordSetString(hrec, 2, "hoo");
1687 ok( r == ERROR_SUCCESS, "set string failed\n");
1688 sz = sizeof buffer;
1689 r = MsiFormatRecord(package, hrec, buffer, &sz);
1690 ok( r == ERROR_SUCCESS, "format failed\n");
1691 ok( sz == 9, "size wrong(%i)\n",sz);
1692 ok( 0 == strcmp(buffer,"boo hoo 3"), "wrong output (%s)\n",buffer);
1694 r = MsiRecordSetString(hrec, 0, "[1] [2] [\\x]");
1695 r = MsiRecordSetString(hrec, 1, "boo");
1696 r = MsiRecordSetString(hrec, 2, "hoo");
1697 ok( r == ERROR_SUCCESS, "set string failed\n");
1698 sz = sizeof buffer;
1699 r = MsiFormatRecord(package, hrec, buffer, &sz);
1700 ok( r == ERROR_SUCCESS, "format failed\n");
1701 ok( sz == 9, "size wrong(%i)\n",sz);
1702 ok( 0 == strcmp(buffer,"boo hoo x"), "wrong output (%s)\n",buffer);
1704 MsiRecordSetString(hrec, 0, "[\\x]");
1705 sz = sizeof buffer;
1706 r = MsiFormatRecord(package, hrec, buffer, &sz);
1707 ok( r == ERROR_SUCCESS, "format failed\n");
1708 ok( sz == 1, "size wrong: %d\n", sz);
1709 ok( 0 == strcmp(buffer,"x"), "wrong output: %s\n", buffer);
1711 MsiRecordSetString(hrec, 0, "{\\x}");
1712 sz = sizeof buffer;
1713 r = MsiFormatRecord(package, hrec, buffer, &sz);
1714 ok( r == ERROR_SUCCESS, "format failed\n");
1715 ok( sz == 4, "size wrong: %d\n", sz);
1716 ok( 0 == strcmp(buffer,"{\\x}"), "wrong output: %s\n", buffer);
1718 MsiRecordSetString(hrec, 0, "[abc\\x]");
1719 sz = sizeof buffer;
1720 r = MsiFormatRecord(package, hrec, buffer, &sz);
1721 ok( r == ERROR_SUCCESS, "format failed\n");
1722 ok( sz == 0, "size wrong: %d\n", sz);
1723 ok( 0 == strcmp(buffer,""), "wrong output: %s\n", buffer);
1725 MsiRecordSetString(hrec, 0, "[abc\\xdef]");
1726 sz = sizeof buffer;
1727 r = MsiFormatRecord(package, hrec, buffer, &sz);
1728 ok( r == ERROR_SUCCESS, "format failed\n");
1729 ok( sz == 0, "size wrong: %d\n", sz);
1730 ok( 0 == strcmp(buffer,""), "wrong output: %s\n", buffer);
1732 MsiRecordSetString(hrec, 0, "\\x");
1733 sz = sizeof(buffer);
1734 r = MsiFormatRecord(package, hrec, buffer, &sz);
1735 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1736 ok(sz == 2, "Expected 2, got %d\n", sz);
1737 ok(!lstrcmpA(buffer, "\\x"), "Expected \"\\x\", got \"%s\"\n", buffer);
1739 MsiRecordSetString(hrec, 0, "[\\[");
1740 sz = sizeof(buffer);
1741 r = MsiFormatRecord(package, hrec, buffer, &sz);
1742 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1743 ok(sz == 3, "Expected 3, got %d\n", sz);
1744 ok(!lstrcmpA(buffer, "[\\["), "Expected \"[\\[\", got \"%s\"\n", buffer);
1746 MsiRecordSetString(hrec, 0, "[\\[]");
1747 sz = sizeof(buffer);
1748 r = MsiFormatRecord(package, hrec, buffer, &sz);
1749 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1750 ok(sz == 1, "Expected 1, got %d\n", sz);
1751 ok(!lstrcmpA(buffer, "["), "Expected \"[\", got \"%s\"\n", buffer);
1753 MsiRecordSetString(hrec, 0, "[[]");
1754 sz = sizeof(buffer);
1755 r = MsiFormatRecord(package, hrec, buffer, &sz);
1756 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1757 ok(sz == 3, "Expected 3, got %d\n", sz);
1758 ok(!lstrcmpA(buffer, "[[]"), "Expected \"[]\", got \"%s\"\n", buffer);
1760 MsiRecordSetString(hrec, 0, "[\\[]]");
1761 sz = sizeof(buffer);
1762 r = MsiFormatRecord(package, hrec, buffer, &sz);
1763 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1764 ok(sz == 2, "Expected 2, got %d\n", sz);
1765 ok(!lstrcmpA(buffer, "[]"), "Expected \"[]\", got \"%s\"\n", buffer);
1767 MsiRecordSetString(hrec, 0, "[\\[a]");
1768 sz = sizeof(buffer);
1769 r = MsiFormatRecord(package, hrec, buffer, &sz);
1770 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1771 ok(sz == 1, "Expected 1, got %d\n", sz);
1772 ok(!lstrcmpA(buffer, "["), "Expected \"[\", got \"%s\"\n", buffer);
1774 MsiRecordSetString(hrec, 0, "[\\a[]");
1775 sz = sizeof(buffer);
1776 r = MsiFormatRecord(package, hrec, buffer, &sz);
1777 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1778 todo_wine
1780 ok(sz == 1, "Expected 1, got %d\n", sz);
1781 ok(!lstrcmpA(buffer, "a"), "Expected \"a\", got \"%s\"\n", buffer);
1784 MsiRecordSetString(hrec, 0, "[prop]");
1785 sz = sizeof(buffer);
1786 r = MsiFormatRecord(package, hrec, buffer, &sz);
1787 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1788 ok(sz == 3, "Expected 3, got %d\n", sz);
1789 ok(!lstrcmpA(buffer, "val"), "Expected \"val\", got \"%s\"\n", buffer);
1791 MsiRecordSetString(hrec, 0, "[prop] [pro\\pblah] [prop]");
1792 sz = sizeof(buffer);
1793 r = MsiFormatRecord(package, hrec, buffer, &sz);
1794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1795 ok(sz == 8, "Expected 8, got %d\n", sz);
1796 ok(!lstrcmpA(buffer, "val val"), "Expected \"val val\", got \"%s\"\n", buffer);
1798 MsiSetPropertyA(package, "b", "ball");
1799 MsiRecordSetString(hrec, 0, "[\\b]");
1800 sz = sizeof(buffer);
1801 r = MsiFormatRecord(package, hrec, buffer, &sz);
1802 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1803 ok(sz == 1, "Expected 1, got %d\n", sz);
1804 ok(!lstrcmpA(buffer, "b"), "Expected \"b\", got \"%s\"\n", buffer);
1806 MsiRecordSetString(hrec, 0, "[\\c]");
1807 sz = sizeof(buffer);
1808 r = MsiFormatRecord(package, hrec, buffer, &sz);
1809 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1810 ok(sz == 1, "Expected 1, got %d\n", sz);
1811 ok(!lstrcmpA(buffer, "c"), "Expected \"c\", got \"%s\"\n", buffer);
1813 MsiRecordSetString(hrec, 0, "[\\[]prop]");
1814 sz = sizeof(buffer);
1815 r = MsiFormatRecord(package, hrec, buffer, &sz);
1816 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1817 ok(sz == 6, "Expected 6, got %d\n", sz);
1818 ok(!lstrcmpA(buffer, "[prop]"), "Expected \"[prop]\", got \"%s\"\n", buffer);
1820 MsiRecordSetString(hrec, 0, "[\\a]prop]");
1821 sz = sizeof(buffer);
1822 r = MsiFormatRecord(package, hrec, buffer, &sz);
1823 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1824 ok(sz == 6, "Expected 6, got %d\n", sz);
1825 ok(!lstrcmpA(buffer, "aprop]"), "Expected \"aprop]\", got \"%s\"\n", buffer);
1827 MsiRecordSetString(hrec, 0, "[\\[]Bracket Text[\\]]");
1828 sz = sizeof buffer;
1829 r = MsiFormatRecord(package, hrec, buffer, &sz);
1830 ok( r == ERROR_SUCCESS, "format failed\n");
1831 ok( sz == 14, "size wrong: %d\n", sz);
1832 ok( 0 == strcmp(buffer,"[Bracket Text]"), "wrong output: %s\n", buffer);
1834 /* null characters */
1835 r = MsiRecordSetString(hrec, 0, "[1] [~] [2]");
1836 r = MsiRecordSetString(hrec, 1, "boo");
1837 r = MsiRecordSetString(hrec, 2, "hoo");
1838 ok( r == ERROR_SUCCESS, "set string failed\n");
1839 sz = sizeof buffer;
1840 r = MsiFormatRecord(package, hrec, buffer, &sz);
1841 ok( r == ERROR_SUCCESS, "format failed\n");
1842 ok( sz == 9, "size wrong: %d\n", sz);
1843 ok( 0 == strcmp(buffer,"boo "), "wrong output: %s\n", buffer);
1844 ok(!lstrcmpA(&buffer[5], " hoo"),
1845 "Expected \" hoo\", got \"%s\"\n", &buffer[5]);
1847 MsiRecordSetString(hrec, 0, "[1] [~abc] [2]");
1848 MsiRecordSetString(hrec, 1, "boo");
1849 MsiRecordSetString(hrec, 2, "hoo");
1850 sz = sizeof(buffer);
1851 r = MsiFormatRecord(package, hrec, buffer, &sz);
1852 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1853 ok(sz == 8, "Expected 8, got %d\n", sz);
1854 ok(!lstrcmpA(buffer, "boo hoo"), "Expected \"boo hoo\", got \"%s\"\n", buffer);
1856 /* properties */
1857 r = MsiSetProperty(package,"dummy","Bork");
1858 ok( r == ERROR_SUCCESS, "set property failed\n");
1859 r = MsiRecordSetString(hrec, 0, "[1] [dummy] [2]");
1860 r = MsiRecordSetString(hrec, 1, "boo");
1861 r = MsiRecordSetString(hrec, 2, "hoo");
1862 ok( r == ERROR_SUCCESS, "set string failed\n");
1863 sz = sizeof buffer;
1864 r = MsiFormatRecord(package, hrec, buffer, &sz);
1865 ok( r == ERROR_SUCCESS, "format failed\n");
1866 ok( sz == 12, "size wrong\n");
1867 ok( 0 == strcmp(buffer,"boo Bork hoo"), "wrong output\n");
1869 r = MsiRecordSetString(hrec, 0, "[1] [invalid] [2]");
1870 r = MsiRecordSetString(hrec, 1, "boo");
1871 r = MsiRecordSetString(hrec, 2, "hoo");
1872 ok( r == ERROR_SUCCESS, "set string failed\n");
1873 sz = sizeof buffer;
1874 r = MsiFormatRecord(package, hrec, buffer, &sz);
1875 ok( r == ERROR_SUCCESS, "format failed\n");
1876 ok( sz == 8, "size wrong\n");
1877 ok( 0 == strcmp(buffer,"boo hoo"), "wrong output\n");
1879 /* nesting tests */
1880 r = MsiSetProperty(package,"dummya","foo");
1881 r = MsiSetProperty(package,"dummyb","baa");
1882 r = MsiSetProperty(package,"adummyc","whoa");
1883 ok( r == ERROR_SUCCESS, "set property failed\n");
1884 r = MsiRecordSetString(hrec, 0, "[dummy[1]] [dummy[2]] [[1]dummy[3]]");
1885 r = MsiRecordSetString(hrec, 1, "a");
1886 r = MsiRecordSetString(hrec, 2, "b");
1887 r = MsiRecordSetString(hrec, 3, "c");
1888 ok( r == ERROR_SUCCESS, "set string failed\n");
1889 sz = sizeof buffer;
1890 r = MsiFormatRecord(package, hrec, buffer, &sz);
1891 ok( r == ERROR_SUCCESS, "format failed\n");
1892 ok( sz == 12, "size wrong(%i)\n",sz);
1893 ok( 0 == strcmp(buffer,"foo baa whoa"), "wrong output (%s)\n",buffer);
1895 r = MsiSetProperty(package,"dummya","1");
1896 r = MsiSetProperty(package,"dummyb","[2]");
1897 ok( r == ERROR_SUCCESS, "set property failed\n");
1898 r = MsiRecordSetString(hrec, 0, "[dummya] [[dummya]] [dummyb]");
1899 r = MsiRecordSetString(hrec, 1, "aaa");
1900 r = MsiRecordSetString(hrec, 2, "bbb");
1901 r = MsiRecordSetString(hrec, 3, "ccc");
1902 ok( r == ERROR_SUCCESS, "set string failed\n");
1903 sz = sizeof buffer;
1904 r = MsiFormatRecord(package, hrec, buffer, &sz);
1905 ok( r == ERROR_SUCCESS, "format failed\n");
1906 todo_wine
1908 ok( sz == 9, "size wrong(%i)\n",sz);
1909 ok( 0 == strcmp(buffer,"1 [1] [2]"), "wrong output (%s)\n",buffer);
1912 r = MsiSetProperty(package,"dummya","1");
1913 r = MsiSetProperty(package,"dummyb","a");
1914 r = MsiSetProperty(package,"dummyc","\\blath");
1915 r = MsiSetProperty(package,"dummyd","[\\blath]");
1916 ok( r == ERROR_SUCCESS, "set property failed\n");
1917 r = MsiRecordSetString(hrec, 0, "[dummyc] [[dummyc]] [dummy[dummyb]]");
1918 r = MsiRecordSetString(hrec, 1, "aaa");
1919 r = MsiRecordSetString(hrec, 2, "bbb");
1920 r = MsiRecordSetString(hrec, 3, "ccc");
1921 ok( r == ERROR_SUCCESS, "set string failed\n");
1922 sz = sizeof buffer;
1923 r = MsiFormatRecord(package, hrec, buffer, &sz);
1924 ok( r == ERROR_SUCCESS, "format failed\n");
1925 ok( sz == 10, "size wrong(%i)\n",sz);
1926 ok( 0 == strcmp(buffer,"\\blath b 1"), "wrong output (%s)\n",buffer);
1928 r = MsiRecordSetString(hrec, 0, "[1] [2] [[\\3asdf]]");
1929 r = MsiRecordSetString(hrec, 1, "boo");
1930 r = MsiRecordSetString(hrec, 2, "hoo");
1931 r = MsiRecordSetString(hrec, 3, "yeah");
1932 ok( r == ERROR_SUCCESS, "set string failed\n");
1933 sz = sizeof buffer;
1934 r = MsiFormatRecord(package, hrec, buffer, &sz);
1935 ok( r == ERROR_SUCCESS, "format failed\n");
1936 todo_wine
1938 ok( sz == 11, "size wrong(%i)\n",sz);
1939 ok( 0 == strcmp(buffer,"boo hoo [3]"), "wrong output (%s)\n",buffer);
1942 r = MsiRecordSetString(hrec, 0, "[1] [2] [[3]]");
1943 r = MsiRecordSetString(hrec, 1, "boo");
1944 r = MsiRecordSetString(hrec, 2, "hoo");
1945 r = MsiRecordSetString(hrec, 3, "\\help");
1946 ok( r == ERROR_SUCCESS, "set string failed\n");
1947 sz = sizeof buffer;
1948 r = MsiFormatRecord(package, hrec, buffer, &sz);
1949 ok( r == ERROR_SUCCESS, "format failed\n");
1950 ok( sz == 9, "size wrong(%i)\n",sz);
1951 ok( 0 == strcmp(buffer,"boo hoo h"), "wrong output (%s)\n",buffer);
1953 /* nested properties */
1954 MsiSetProperty(package, "PropA", "surprise");
1955 MsiSetProperty(package, "PropB", "[PropA]");
1956 MsiSetProperty(package, "PropC", "[PropB]");
1957 sz = sizeof buffer;
1958 MsiRecordSetString(hrec, 0, "[PropC]");
1959 r = MsiFormatRecord(package, hrec, buffer, &sz);
1960 ok( r == ERROR_SUCCESS, "format failed\n");
1961 ok( sz == 7, "size wrong(%i)\n",sz);
1962 ok( 0 == strcmp(buffer,"[PropB]"), "wrong output (%s)\n",buffer);
1964 MsiSetProperty(package, "PropA", "surprise");
1965 MsiSetProperty(package, "PropB", "PropA");
1966 MsiSetProperty(package, "PropC", "PropB");
1967 sz = sizeof buffer;
1968 MsiRecordSetString(hrec, 0, "[PropC]");
1969 r = MsiFormatRecord(package, hrec, buffer, &sz);
1970 ok( r == ERROR_SUCCESS, "format failed\n");
1971 ok( sz == 5, "size wrong(%i)\n",sz);
1972 ok( 0 == strcmp(buffer,"PropB"), "wrong output (%s)\n",buffer);
1974 MsiSetProperty(package, "PropA", "surprise");
1975 MsiSetProperty(package, "PropB", "[PropA]");
1976 MsiSetProperty(package, "PropC", "[PropB]");
1977 sz = sizeof buffer;
1978 MsiRecordSetString(hrec, 0, "[[PropC]]");
1979 r = MsiFormatRecord(package, hrec, buffer, &sz);
1980 ok( r == ERROR_SUCCESS, "format failed\n");
1981 ok( sz == 0, "size wrong(%i)\n",sz);
1982 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
1984 MsiSetProperty(package, "PropA", "surprise");
1985 MsiSetProperty(package, "PropB", "[PropA]");
1986 MsiSetProperty(package, "PropC", "PropB");
1987 sz = sizeof buffer;
1988 MsiRecordSetString(hrec, 0, "[[PropC]]");
1989 r = MsiFormatRecord(package, hrec, buffer, &sz);
1990 ok( r == ERROR_SUCCESS, "format failed\n");
1991 ok( sz == 7, "size wrong(%i)\n",sz);
1992 ok( 0 == strcmp(buffer,"[PropA]"), "wrong output (%s)\n",buffer);
1994 MsiSetProperty(package, "PropA", "surprise");
1995 MsiSetProperty(package, "PropB", "PropA");
1996 MsiSetProperty(package, "PropC", "PropB");
1997 sz = sizeof buffer;
1998 MsiRecordSetString(hrec, 0, "[[PropC]]");
1999 r = MsiFormatRecord(package, hrec, buffer, &sz);
2000 ok( r == ERROR_SUCCESS, "format failed\n");
2001 ok( sz == 5, "size wrong(%i)\n",sz);
2002 ok( 0 == strcmp(buffer,"PropA"), "wrong output (%s)\n",buffer);
2004 MsiSetProperty(package, "PropA", "surprise");
2005 MsiSetProperty(package, "PropB", "PropA");
2006 MsiSetProperty(package, "PropC", "PropB");
2007 sz = sizeof buffer;
2008 MsiRecordSetString(hrec, 0, "[[[PropC]]]");
2009 r = MsiFormatRecord(package, hrec, buffer, &sz);
2010 ok( r == ERROR_SUCCESS, "format failed\n");
2011 ok( sz == 8, "size wrong(%i)\n",sz);
2012 ok( 0 == strcmp(buffer,"surprise"), "wrong output (%s)\n",buffer);
2014 /* properties inside braces */
2015 sz = sizeof buffer;
2016 MsiRecordSetString(hrec, 0, "{abcd}");
2017 r = MsiFormatRecord(package, hrec, buffer, &sz);
2018 ok( r == ERROR_SUCCESS, "format failed\n");
2019 ok( sz == 6, "size wrong(%i)\n",sz);
2020 ok( 0 == strcmp(buffer,"{abcd}"), "wrong output (%s)\n",buffer);
2022 MsiSetProperty(package, "one", "mercury");
2023 MsiSetProperty(package, "two", "venus");
2024 sz = sizeof buffer;
2025 MsiRecordSetString(hrec, 0, "{a[one]bc[two]de[one]f}");
2026 r = MsiFormatRecord(package, hrec, buffer, &sz);
2027 ok( r == ERROR_SUCCESS, "format failed: %d\n", r);
2028 ok( sz == 25, "size wrong(%i)\n",sz);
2029 ok( 0 == strcmp(buffer,"amercurybcvenusdemercuryf"), "wrong output (%s)\n",buffer);
2031 MsiSetProperty(package, "one", "mercury");
2032 MsiSetProperty(package, "two", "venus");
2033 MsiSetProperty(package, "bad", "");
2034 sz = sizeof buffer;
2035 MsiRecordSetString(hrec, 0, "{a[one]bc[bad]de[two]f}");
2036 r = MsiFormatRecord(package, hrec, buffer, &sz);
2037 ok( r == ERROR_SUCCESS, "format failed\n");
2038 ok( sz == 0, "size wrong(%i)\n",sz);
2039 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
2041 MsiSetProperty(package, "bad", "");
2042 sz = sizeof buffer;
2043 MsiRecordSetString(hrec, 0, "{[bad]}");
2044 r = MsiFormatRecord(package, hrec, buffer, &sz);
2045 ok( r == ERROR_SUCCESS, "format failed\n");
2046 ok( sz == 0, "size wrong(%i)\n",sz);
2047 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
2049 MsiSetProperty(package, "one", "mercury");
2050 sz = sizeof buffer;
2051 MsiRecordSetString(hrec, 0, "{abc{d[one]ef}"); /* missing final brace */
2052 r = MsiFormatRecord(package, hrec, buffer, &sz);
2053 ok( r == ERROR_SUCCESS, "format failed\n");
2054 todo_wine
2056 ok( sz == 14, "size wrong(%i)\n",sz);
2057 ok( 0 == strcmp(buffer,"abc{dmercuryef"), "wrong output (%s)\n",buffer);
2060 MsiSetProperty(package, "one", "mercury");
2061 sz = sizeof buffer;
2062 MsiRecordSetString(hrec, 0, "{abc{d[one]ef}}");
2063 r = MsiFormatRecord(package, hrec, buffer, &sz);
2064 ok( r == ERROR_SUCCESS, "format failed\n");
2065 todo_wine
2067 ok( sz == 15, "size wrong(%i)\n",sz);
2068 ok( 0 == strcmp(buffer,"abc{dmercuryef}"), "wrong output (%s)\n",buffer);
2071 MsiSetProperty(package, "one", "mercury");
2072 sz = sizeof buffer;
2073 MsiRecordSetString(hrec, 0, "{abc}{{def}hi{j[one]k}}");
2074 r = MsiFormatRecord(package, hrec, buffer, &sz);
2075 ok( r == ERROR_SUCCESS, "format failed\n");
2076 ok( sz == 5, "size wrong(%i)\n",sz);
2077 ok( 0 == strcmp(buffer,"{abc}"), "wrong output (%s)\n",buffer);
2079 MsiSetProperty(package, "one", "mercury");
2081 sz = sizeof buffer;
2082 MsiRecordSetString(hrec, 0, "{{def}hi{j[one]k}}");
2083 r = MsiFormatRecord(package, hrec, buffer, &sz);
2084 ok( r == ERROR_SUCCESS, "format failed\n");
2085 ok( sz == 0, "size wrong(%i)\n",sz);
2086 ok( 0 == strcmp(buffer,""), "wrong output (%s)\n",buffer);
2088 sz = sizeof(buffer);
2089 MsiRecordSetString(hrec, 0, "[1] {[noprop] [twoprop]} {abcdef}");
2090 MsiRecordSetString(hrec, 1, "one");
2091 r = MsiFormatRecord(package, hrec, buffer, &sz);
2092 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2093 ok(sz == 13, "Expected 13, got %d\n",sz);
2094 ok(!lstrcmpA(buffer, "one {abcdef}"),
2095 "Expected \"one {abcdef}\", got \"%s\"\n", buffer);
2097 sz = sizeof(buffer);
2098 MsiRecordSetString(hrec, 0, "[1] {[noprop] [one]} {abcdef}");
2099 MsiRecordSetString(hrec, 1, "one");
2100 r = MsiFormatRecord(package, hrec, buffer, &sz);
2101 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2102 ok(sz == 13, "Expected 13, got %d\n",sz);
2103 ok(!lstrcmpA(buffer, "one {abcdef}"),
2104 "Expected \"one {abcdef}\", got \"%s\"\n", buffer);
2106 sz = sizeof(buffer);
2107 MsiRecordSetString(hrec, 0, "[1] {[one]} {abcdef}");
2108 MsiRecordSetString(hrec, 1, "one");
2109 r = MsiFormatRecord(package, hrec, buffer, &sz);
2110 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2111 ok(sz == 20, "Expected 20, got %d\n",sz);
2112 ok(!lstrcmpA(buffer, "one mercury {abcdef}"),
2113 "Expected \"one mercury {abcdef}\", got \"%s\"\n", buffer);
2115 MsiCloseHandle(hrec);
2117 r = MsiCloseHandle(package);
2118 ok(r==ERROR_SUCCESS, "Unable to close package\n");
2120 DeleteFile( filename );
2123 static void test_formatrecord_tables(void)
2125 MSIHANDLE hdb, hpkg, hrec;
2126 CHAR buf[MAX_PATH];
2127 CHAR curr_dir[MAX_PATH];
2128 CHAR expected[MAX_PATH];
2129 CHAR root[MAX_PATH];
2130 DWORD size;
2131 UINT r;
2133 GetCurrentDirectory( MAX_PATH, curr_dir );
2135 hdb = create_package_db();
2136 ok ( hdb, "failed to create package database\n");
2138 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
2139 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r);
2141 r = add_directory_entry( hdb, "'ReallyLongDir', 'TARGETDIR', "
2142 "'I am a really long directory'" );
2143 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r);
2145 r = create_feature_table( hdb );
2146 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r);
2148 r = add_feature_entry( hdb, "'occipitofrontalis', '', '', '', 2, 1, '', 0" );
2149 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2151 r = create_component_table( hdb );
2152 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r);
2154 r = add_component_entry( hdb, "'frontal', '', 'TARGETDIR', 0, '', 'frontal_file'" );
2155 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r);
2157 r = add_component_entry( hdb, "'parietal', '', 'TARGETDIR', 1, '', 'parietal_file'" );
2158 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r);
2160 r = add_component_entry( hdb, "'temporal', '', 'ReallyLongDir', 0, '', 'temporal_file'" );
2161 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r);
2163 r = create_feature_components_table( hdb );
2164 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r);
2166 r = add_feature_components_entry( hdb, "'occipitofrontalis', 'frontal'" );
2167 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r);
2169 r = add_feature_components_entry( hdb, "'occipitofrontalis', 'parietal'" );
2170 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r);
2172 r = add_feature_components_entry( hdb, "'occipitofrontalis', 'temporal'" );
2173 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r);
2175 r = create_file_table( hdb );
2176 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r);
2178 r = add_file_entry( hdb, "'frontal_file', 'frontal', 'frontal.txt', 0, '', '1033', 8192, 1" );
2179 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2181 r = add_file_entry( hdb, "'parietal_file', 'parietal', 'parietal.txt', 0, '', '1033', 8192, 1" );
2182 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2184 r = add_file_entry( hdb, "'temporal_file', 'temporal', 'temporal.txt', 0, '', '1033', 8192, 1" );
2185 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2187 r = create_custom_action_table( hdb );
2188 ok( r == ERROR_SUCCESS, "cannot create CustomAction table: %d\n", r);
2190 r = add_custom_action_entry( hdb, "'MyCustom', 51, 'prop', '[!temporal_file]'" );
2191 ok( r == ERROR_SUCCESS, "cannt add custom action: %d\n", r);
2193 r = add_custom_action_entry( hdb, "'EscapeIt1', 51, 'prop', '[\\[]Bracket Text[\\]]'" );
2194 ok( r == ERROR_SUCCESS, "cannt add custom action: %d\n", r);
2196 r = add_custom_action_entry( hdb, "'EscapeIt2', 51, 'prop', '[\\xabcd]'" );
2197 ok( r == ERROR_SUCCESS, "cannt add custom action: %d\n", r);
2199 r = add_custom_action_entry( hdb, "'EscapeIt3', 51, 'prop', '[abcd\\xefgh]'" );
2200 ok( r == ERROR_SUCCESS, "cannt add custom action: %d\n", r);
2202 hpkg = package_from_db( hdb );
2203 ok( hpkg, "failed to create package\n");
2205 MsiCloseHandle( hdb );
2207 r = MsiSetPropertyA( hpkg, "imaprop", "ringer" );
2208 ok( r == ERROR_SUCCESS, "cannot set property: %d\n", r);
2210 hrec = MsiCreateRecord( 1 );
2212 /* property doesn't exist */
2213 size = MAX_PATH;
2214 /*MsiRecordSetString( hrec, 0, "[1]" ); */
2215 MsiRecordSetString( hrec, 1, "[idontexist]" );
2216 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2217 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2218 ok( !lstrcmp( buf, "1: " ), "Expected '1: ', got %s\n", buf );
2220 /* property exists */
2221 size = MAX_PATH;
2222 MsiRecordSetString( hrec, 1, "[imaprop]" );
2223 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2224 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2225 ok( !lstrcmp( buf, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf );
2227 /* environment variable doesn't exist */
2228 size = MAX_PATH;
2229 MsiRecordSetString( hrec, 1, "[%idontexist]" );
2230 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2231 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2232 ok( !lstrcmp( buf, "1: " ), "Expected '1: ', got %s\n", buf );
2234 /* environment variable exists */
2235 size = MAX_PATH;
2236 SetEnvironmentVariable( "crazyvar", "crazyval" );
2237 MsiRecordSetString( hrec, 1, "[%crazyvar]" );
2238 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2239 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2240 ok( !lstrcmp( buf, "1: crazyval " ), "Expected '1: crazyval ', got %s\n", buf );
2242 /* file key before CostInitialize */
2243 size = MAX_PATH;
2244 MsiRecordSetString( hrec, 1, "[#frontal_file]" );
2245 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2246 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2247 ok( !lstrcmp( buf, "1: " ), "Expected '1: ', got %s\n", buf );
2249 r = MsiDoAction(hpkg, "CostInitialize");
2250 ok( r == ERROR_SUCCESS, "CostInitialize failed: %d\n", r);
2252 r = MsiDoAction(hpkg, "FileCost");
2253 ok( r == ERROR_SUCCESS, "FileCost failed: %d\n", r);
2255 r = MsiDoAction(hpkg, "CostFinalize");
2256 ok( r == ERROR_SUCCESS, "CostFinalize failed: %d\n", r);
2258 size = MAX_PATH;
2259 MsiGetProperty( hpkg, "ROOTDRIVE", root, &size );
2261 sprintf( expected, "1: %sfrontal.txt ", root);
2263 /* frontal full file key */
2264 size = MAX_PATH;
2265 MsiRecordSetString( hrec, 1, "[#frontal_file]" );
2266 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2267 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2268 ok( !lstrcmp( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2270 /* frontal short file key */
2271 size = MAX_PATH;
2272 MsiRecordSetString( hrec, 1, "[!frontal_file]" );
2273 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2274 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2275 ok( !lstrcmp( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2277 sprintf( expected, "1: %sI am a really long directory\\temporal.txt ", root);
2279 /* temporal full file key */
2280 size = MAX_PATH;
2281 MsiRecordSetString( hrec, 1, "[#temporal_file]" );
2282 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2283 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2284 ok( !lstrcmp( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2286 /* temporal short file key */
2287 size = MAX_PATH;
2288 MsiRecordSetString( hrec, 1, "[!temporal_file]" );
2289 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2290 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2291 ok( !lstrcmp( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2293 /* custom action 51, files don't exist */
2294 r = MsiDoAction( hpkg, "MyCustom" );
2295 ok( r == ERROR_SUCCESS, "MyCustom failed: %d\n", r);
2297 sprintf( expected, "%sI am a really long directory\\temporal.txt", root);
2299 size = MAX_PATH;
2300 r = MsiGetProperty( hpkg, "prop", buf, &size );
2301 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2302 ok( !lstrcmp( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2304 sprintf( buf, "%sI am a really long directory", root );
2305 CreateDirectory( buf, NULL );
2307 lstrcat( buf, "\\temporal.txt" );
2308 create_test_file( buf );
2310 /* custom action 51, files exist */
2311 r = MsiDoAction( hpkg, "MyCustom" );
2312 ok( r == ERROR_SUCCESS, "MyCustom failed: %d\n", r);
2314 size = MAX_PATH;
2315 r = MsiGetProperty( hpkg, "prop", buf, &size );
2316 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2317 todo_wine
2319 ok( !lstrcmp( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2322 /* custom action 51, escaped text 1 */
2323 r = MsiDoAction( hpkg, "EscapeIt1" );
2324 ok( r == ERROR_SUCCESS, "EscapeIt failed: %d\n", r);
2326 size = MAX_PATH;
2327 r = MsiGetProperty( hpkg, "prop", buf, &size );
2328 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2329 ok( !lstrcmp( buf, "[Bracket Text]" ), "Expected '[Bracket Text]', got %s\n", buf);
2331 /* custom action 51, escaped text 2 */
2332 r = MsiDoAction( hpkg, "EscapeIt2" );
2333 ok( r == ERROR_SUCCESS, "EscapeIt failed: %d\n", r);
2335 size = MAX_PATH;
2336 r = MsiGetProperty( hpkg, "prop", buf, &size );
2337 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2338 ok( !lstrcmp( buf, "x" ), "Expected 'x', got %s\n", buf);
2340 /* custom action 51, escaped text 3 */
2341 r = MsiDoAction( hpkg, "EscapeIt3" );
2342 ok( r == ERROR_SUCCESS, "EscapeIt failed: %d\n", r);
2344 size = MAX_PATH;
2345 r = MsiGetProperty( hpkg, "prop", buf, &size );
2346 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2347 ok( !lstrcmp( buf, "" ), "Expected '', got %s\n", buf);
2349 sprintf( expected, "1: %sI am a really long directory\\ ", root);
2351 /* component with INSTALLSTATE_LOCAL */
2352 size = MAX_PATH;
2353 MsiRecordSetString( hrec, 1, "[$temporal]" );
2354 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2355 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2356 ok( !lstrcmp( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2358 r = MsiSetComponentState( hpkg, "temporal", INSTALLSTATE_SOURCE );
2359 ok( r == ERROR_SUCCESS, "failed to set install state: %d\n", r);
2361 /* component with INSTALLSTATE_SOURCE */
2362 lstrcpy( expected, "1: " );
2363 lstrcat( expected, curr_dir );
2364 lstrcat( expected, "\\ " );
2365 size = MAX_PATH;
2366 MsiRecordSetString( hrec, 1, "[$parietal]" );
2367 r = MsiFormatRecord( hpkg, hrec, buf, &size );
2368 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2369 ok( !lstrcmp( buf, expected ), "Expected '%s', got %s\n", expected, buf);
2371 sprintf( buf, "%sI am a really long directory\\temporal.txt", root );
2372 DeleteFile( buf );
2374 sprintf( buf, "%sI am a really long directory", root );
2375 RemoveDirectory( buf );
2377 MsiCloseHandle( hrec );
2378 MsiCloseHandle( hpkg );
2379 DeleteFile( msifile );
2382 static void test_processmessage(void)
2384 static const CHAR filename[] = "winetest.msi";
2385 MSIHANDLE hrec;
2386 MSIHANDLE package;
2387 int r;
2389 package = helper_createpackage( filename );
2390 ok(package!=0, "Unable to create package\n");
2392 hrec = MsiCreateRecord(3);
2393 ok( hrec, "failed to create record\n");
2395 r = MsiRecordSetString(hrec, 1, "");
2396 ok( r == ERROR_SUCCESS, "set string failed\n");
2398 r = MsiProcessMessage(package, INSTALLMESSAGE_ACTIONSTART, hrec);
2399 ok( r == IDOK, "expected IDOK, got %i\n", r);
2401 MsiCloseHandle(hrec);
2402 MsiCloseHandle(package);
2404 DeleteFile(filename);
2407 START_TEST(format)
2409 test_createpackage();
2410 test_formatrecord();
2411 test_formatrecord_package();
2412 test_formatrecord_tables();
2413 test_processmessage();