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
28 #include "wine/test.h"
30 static const char msifile
[] = "winetest-format.msi";
31 static const WCHAR msifileW
[] =
32 {'w','i','n','e','t','e','s','t','-','f','o','r','m','a','t','.','m','s','i',0};
34 static UINT
run_query( MSIHANDLE hdb
, const char *query
)
39 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
40 if( r
!= ERROR_SUCCESS
)
43 r
= MsiViewExecute(hview
, 0);
44 if( r
== ERROR_SUCCESS
)
45 r
= MsiViewClose(hview
);
46 MsiCloseHandle(hview
);
50 static UINT
create_feature_table( MSIHANDLE hdb
)
52 return run_query( hdb
,
53 "CREATE TABLE `Feature` ( "
54 "`Feature` CHAR(38) NOT NULL, "
55 "`Feature_Parent` CHAR(38), "
57 "`Description` CHAR(255), "
58 "`Display` SHORT NOT NULL, "
59 "`Level` SHORT NOT NULL, "
60 "`Directory_` CHAR(72), "
61 "`Attributes` SHORT NOT NULL "
62 "PRIMARY KEY `Feature`)" );
65 static UINT
create_component_table( MSIHANDLE hdb
)
67 return run_query( hdb
,
68 "CREATE TABLE `Component` ( "
69 "`Component` CHAR(72) NOT NULL, "
70 "`ComponentId` CHAR(38), "
71 "`Directory_` CHAR(72) NOT NULL, "
72 "`Attributes` SHORT NOT NULL, "
73 "`Condition` CHAR(255), "
75 "PRIMARY KEY `Component`)" );
78 static UINT
create_feature_components_table( MSIHANDLE hdb
)
80 return run_query( hdb
,
81 "CREATE TABLE `FeatureComponents` ( "
82 "`Feature_` CHAR(38) NOT NULL, "
83 "`Component_` CHAR(72) NOT NULL "
84 "PRIMARY KEY `Feature_`, `Component_` )" );
87 static UINT
create_file_table( MSIHANDLE hdb
)
89 return run_query( hdb
,
90 "CREATE TABLE `File` ("
91 "`File` CHAR(72) NOT NULL, "
92 "`Component_` CHAR(72) NOT NULL, "
93 "`FileName` CHAR(255) NOT NULL, "
94 "`FileSize` LONG NOT NULL, "
95 "`Version` CHAR(72), "
96 "`Language` CHAR(20), "
97 "`Attributes` SHORT, "
98 "`Sequence` SHORT NOT NULL "
99 "PRIMARY KEY `File`)" );
102 static UINT
create_custom_action_table( MSIHANDLE hdb
)
104 return run_query( hdb
,
105 "CREATE TABLE `CustomAction` ("
106 "`Action` CHAR(72) NOT NULL, "
107 "`Type` SHORT NOT NULL, "
108 "`Source` CHAR(75), "
109 "`Target` CHAR(255) "
110 "PRIMARY KEY `Action`)" );
113 #define make_add_entry(type, qtext) \
114 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
116 char insert[] = qtext; \
119 sz = strlen(values) + sizeof insert; \
120 query = HeapAlloc(GetProcessHeap(),0,sz); \
121 sprintf(query,insert,values); \
122 r = run_query( hdb, query ); \
123 HeapFree(GetProcessHeap(), 0, query); \
127 make_add_entry(feature
,
128 "INSERT INTO `Feature` "
129 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
130 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
132 make_add_entry(component
,
133 "INSERT INTO `Component` "
134 "(`Component`, `ComponentId`, `Directory_`, "
135 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
137 make_add_entry(feature_components
,
138 "INSERT INTO `FeatureComponents` "
139 "(`Feature_`, `Component_`) VALUES( %s )")
142 "INSERT INTO `File` "
143 "(`File`, `Component_`, `FileName`, `FileSize`, "
144 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
146 make_add_entry(directory
,
147 "INSERT INTO `Directory` "
148 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
150 make_add_entry(custom_action
,
151 "INSERT INTO `CustomAction` "
152 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
154 static UINT
set_summary_info(MSIHANDLE hdb
)
159 /* build summary info */
160 res
= MsiGetSummaryInformationA(hdb
, NULL
, 7, &suminfo
);
161 ok( res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n" );
163 res
= MsiSummaryInfoSetPropertyA(suminfo
,2, VT_LPSTR
, 0,NULL
,
164 "Installation Database");
165 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
167 res
= MsiSummaryInfoSetPropertyA(suminfo
,3, VT_LPSTR
, 0,NULL
,
168 "Installation Database");
169 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
171 res
= MsiSummaryInfoSetPropertyA(suminfo
,4, VT_LPSTR
, 0,NULL
,
173 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
175 res
= MsiSummaryInfoSetPropertyA(suminfo
,7, VT_LPSTR
, 0,NULL
,
177 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
179 res
= MsiSummaryInfoSetPropertyA(suminfo
,9, VT_LPSTR
, 0,NULL
,
180 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
181 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
183 res
= MsiSummaryInfoSetPropertyA(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
184 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
186 res
= MsiSummaryInfoSetPropertyA(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
187 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
189 res
= MsiSummaryInfoPersist(suminfo
);
190 ok( res
== ERROR_SUCCESS
, "Failed to make summary info persist\n" );
192 res
= MsiCloseHandle( suminfo
);
193 ok( res
== ERROR_SUCCESS
, "Failed to close suminfo\n" );
198 static MSIHANDLE
create_package_db(void)
203 DeleteFileW(msifileW
);
205 /* create an empty database */
206 res
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATEDIRECT
, &hdb
);
207 ok( res
== ERROR_SUCCESS
, "Failed to create database %u\n", res
);
208 if( res
!= ERROR_SUCCESS
)
211 res
= MsiDatabaseCommit( hdb
);
212 ok( res
== ERROR_SUCCESS
, "Failed to commit database\n" );
213 if( res
!= ERROR_SUCCESS
)
216 res
= set_summary_info(hdb
);
217 ok( res
== ERROR_SUCCESS
, "Failed to set summary info %u\n", res
);
218 if( res
!= ERROR_SUCCESS
)
221 res
= run_query( hdb
,
222 "CREATE TABLE `Directory` ( "
223 "`Directory` CHAR(255) NOT NULL, "
224 "`Directory_Parent` CHAR(255), "
225 "`DefaultDir` CHAR(255) NOT NULL "
226 "PRIMARY KEY `Directory`)" );
227 ok( res
== ERROR_SUCCESS
, "Failed to create directory table %u\n", res
);
232 static UINT
package_from_db(MSIHANDLE hdb
, MSIHANDLE
*handle
)
238 sprintf(szPackage
, "#%u", hdb
);
239 res
= MsiOpenPackageA(szPackage
, &hPackage
);
240 if (res
!= ERROR_SUCCESS
)
243 res
= MsiCloseHandle(hdb
);
244 if (res
!= ERROR_SUCCESS
)
246 MsiCloseHandle(hPackage
);
251 return ERROR_SUCCESS
;
254 static void create_test_file(const CHAR
*name
)
259 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
260 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
261 WriteFile(file
, name
, strlen(name
), &written
, NULL
);
262 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
266 static UINT
helper_createpackage( const char *szName
, MSIHANDLE
*handle
)
268 MSIHANDLE hPackage
, suminfo
, hdb
= 0;
275 len
= MultiByteToWideChar( CP_ACP
, 0, szName
, -1, NULL
, 0 );
276 if (!(nameW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) )))
277 return ERROR_OUTOFMEMORY
;
278 MultiByteToWideChar( CP_ACP
, 0, szName
, -1, nameW
, len
);
280 /* create an empty database */
281 res
= MsiOpenDatabaseW( nameW
, MSIDBOPEN_CREATEDIRECT
, &hdb
);
282 HeapFree( GetProcessHeap(), 0, nameW
);
283 ok( res
== ERROR_SUCCESS
, "Failed to create database %u\n", res
);
284 if (res
!= ERROR_SUCCESS
)
287 res
= MsiDatabaseCommit( hdb
);
288 ok( res
== ERROR_SUCCESS
, "Failed to commit database %u\n", res
);
290 /* build summary info */
291 res
= MsiGetSummaryInformationA(hdb
, NULL
, 7, &suminfo
);
292 ok( res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n" );
294 res
= MsiSummaryInfoSetPropertyA(suminfo
,2, VT_LPSTR
, 0,NULL
,
295 "Installation Database");
296 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
298 res
= MsiSummaryInfoSetPropertyA(suminfo
,3, VT_LPSTR
, 0,NULL
,
299 "Installation Database");
300 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
302 res
= MsiSummaryInfoSetPropertyA(suminfo
,4, VT_LPSTR
, 0,NULL
,
304 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
306 res
= MsiSummaryInfoSetPropertyA(suminfo
,7, VT_LPSTR
, 0,NULL
,
308 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
310 res
= MsiSummaryInfoSetPropertyA(suminfo
,9, VT_LPSTR
, 0,NULL
,
311 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
312 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
314 res
= MsiSummaryInfoSetPropertyA(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
315 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
317 res
= MsiSummaryInfoSetPropertyA(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
318 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
320 res
= MsiSummaryInfoPersist(suminfo
);
321 ok( res
== ERROR_SUCCESS
, "Failed to make summary info persist\n" );
323 res
= MsiCloseHandle( suminfo
);
324 ok( res
== ERROR_SUCCESS
, "Failed to close suminfo\n" );
326 res
= package_from_db( hdb
, &hPackage
);
329 if (res
!= ERROR_SUCCESS
)
330 DeleteFileA( szName
);
337 static void test_createpackage(void)
339 MSIHANDLE hPackage
= 0;
342 res
= helper_createpackage( msifile
, &hPackage
);
343 if (res
== ERROR_INSTALL_PACKAGE_REJECTED
)
345 skip("Not enough rights to perform tests\n");
348 ok( res
== ERROR_SUCCESS
, "Failed to create package %u\n", res
);
350 res
= MsiCloseHandle( hPackage
);
351 ok( res
== ERROR_SUCCESS
, "Failed to close package %u\n", res
);
353 DeleteFileA( msifile
);
356 static void test_formatrecord(void)
363 r
= MsiFormatRecordA(0, 0, NULL
, NULL
);
364 ok( r
== ERROR_INVALID_HANDLE
, "wrong error\n");
366 hrec
= MsiCreateRecord(0);
367 ok( hrec
, "failed to create record\n");
369 /* format an empty record on a record with no parameters */
371 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
372 ok( r
== ERROR_SUCCESS
, "format failed\n");
373 ok( sz
== 0, "size wrong\n");
375 MsiCloseHandle( hrec
);
377 hrec
= MsiCreateRecord(4);
378 ok( hrec
, "failed to create record\n");
380 /* format an empty record */
381 r
= MsiFormatRecordA(0, hrec
, NULL
, NULL
);
382 ok( r
== ERROR_SUCCESS
, "format failed\n");
386 r
= MsiFormatRecordA(0, hrec
, buffer
+1, &sz
);
387 ok( r
== ERROR_MORE_DATA
&& buffer
[0] == 'x', "format failed measuring with buffer\n");
388 ok( sz
== 16, "size wrong\n");
390 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
391 ok( r
== ERROR_SUCCESS
, "format failed with empty buffer\n");
392 ok( sz
== 16, "size wrong\n");
393 ok( 0 == strcmp(buffer
,"1: 2: 3: 4: "), "wrong output\n");
395 r
= MsiCloseHandle(hrec
);
396 ok(r
==ERROR_SUCCESS
, "Unable to close record\n");
398 hrec
= MsiCreateRecord(6);
399 ok( hrec
, "failed to create record\n");
404 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
405 ok( r
== ERROR_SUCCESS
, "format failed with empty buffer\n");
406 ok( sz
== 24, "size wrong\n");
407 ok( 0 == strcmp(buffer
,"1: 2: 3: 4: 5: 6: "), "wrong output\n");
410 /* format a format string with everything else empty */
411 r
= MsiRecordSetStringA(hrec
, 0, "%1");
412 ok( r
== ERROR_SUCCESS
, "set string failed\n");
413 r
= MsiFormatRecordA(0, hrec
, NULL
, NULL
);
414 ok( r
== ERROR_SUCCESS
, "format failed\n");
415 r
= MsiFormatRecordA(0, hrec
, buffer
, NULL
);
416 ok( r
== ERROR_INVALID_PARAMETER
, "wrong error\n");
419 r
= MsiFormatRecordA(0, hrec
, NULL
, &sz
);
420 ok( r
== ERROR_SUCCESS
, "format failed with empty buffer\n");
421 ok( sz
== 2, "size wrong (%i)\n",sz
);
425 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
426 ok( r
== ERROR_SUCCESS
, "format failed with empty buffer\n");
427 ok( sz
== 2, "size wrong\n");
428 ok( 0 == strcmp(buffer
,"%1"), "wrong output\n");
430 /* make the buffer too small */
434 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
435 ok( r
== ERROR_MORE_DATA
, "format failed with empty buffer\n");
436 ok( sz
== 2, "size wrong\n");
437 ok( 0 == strcmp(buffer
,"x"), "wrong output\n");
439 /* make the buffer a little bit bigger */
443 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
444 ok( r
== ERROR_MORE_DATA
, "format failed with empty buffer\n");
445 ok( sz
== 2, "size wrong\n");
446 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
452 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
453 ok( r
== ERROR_MORE_DATA
, "format failed with empty buffer\n");
454 ok( sz
== 2, "size wrong\n");
455 ok( 0 == strcmp(buffer
,"%"), "wrong output\n");
461 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
462 ok( r
== ERROR_SUCCESS
, "format failed with empty buffer\n");
463 ok( sz
== 2, "size wrong\n");
464 ok( 0 == strcmp(buffer
,"%1"), "wrong output\n");
466 /* now try a real format string */
467 r
= MsiRecordSetStringA(hrec
, 0, "[1]");
468 ok( r
== ERROR_SUCCESS
, "set string failed\n");
470 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
471 ok( r
== ERROR_SUCCESS
, "format failed\n");
472 ok( sz
== 0, "size wrong\n");
473 ok( 0 == strcmp(buffer
,""), "wrong output\n");
475 /* now put something in the first field */
476 r
= MsiRecordSetStringA(hrec
, 1, "boo hoo");
477 ok( r
== ERROR_SUCCESS
, "set string failed\n");
479 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
480 ok( r
== ERROR_SUCCESS
, "format failed\n");
481 ok( sz
== 7, "size wrong\n");
482 ok( 0 == strcmp(buffer
,"boo hoo"), "wrong output\n");
484 /* now put something in the first field */
485 r
= MsiRecordSetStringA(hrec
, 0, "[1] [2]");
486 ok( r
== ERROR_SUCCESS
, "set string failed\n");
487 r
= MsiRecordSetStringA(hrec
, 1, "boo");
488 ok( r
== ERROR_SUCCESS
, "set string failed\n");
489 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
490 ok( r
== ERROR_SUCCESS
, "set string failed\n");
492 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
493 ok( r
== ERROR_SUCCESS
, "format failed\n");
494 ok( sz
== 7, "size wrong\n");
495 ok( 0 == strcmp(buffer
,"boo hoo"), "wrong output\n");
498 r
= MsiRecordSetStringA(hrec
, 0, "");
499 ok( r
== ERROR_SUCCESS
, "set string failed\n");
501 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
502 ok( r
== ERROR_SUCCESS
, "format failed\n");
503 ok( sz
== 30, "size wrong %i\n",sz
);
504 ok( 0 == strcmp(buffer
,"1: boo 2: hoo 3: 4: 5: 6: "),
505 "wrong output(%s)\n",buffer
);
507 /* play games with recursive lookups */
508 r
= MsiRecordSetStringA(hrec
, 0, "[[1]] [2]");
509 ok( r
== ERROR_SUCCESS
, "set string failed\n");
510 r
= MsiRecordSetStringA(hrec
, 1, "2");
511 ok( r
== ERROR_SUCCESS
, "set string failed\n");
512 r
= MsiRecordSetStringA(hrec
, 2, "hey");
513 ok( r
== ERROR_SUCCESS
, "set string failed\n");
515 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
516 ok( r
== ERROR_SUCCESS
, "format failed\n");
517 ok( sz
== 7, "size wrong,(%i)\n",sz
);
518 ok( 0 == strcmp(buffer
,"hey hey"), "wrong output (%s)\n",buffer
);
520 r
= MsiRecordSetStringA(hrec
, 0, "[[1]] [2]");
521 ok( r
== ERROR_SUCCESS
, "set string failed\n");
522 r
= MsiRecordSetStringA(hrec
, 1, "[2]");
523 ok( r
== ERROR_SUCCESS
, "set string failed\n");
524 r
= MsiRecordSetStringA(hrec
, 2, "hey");
525 ok( r
== ERROR_SUCCESS
, "set string failed\n");
527 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
528 ok( r
== ERROR_SUCCESS
, "format failed\n");
529 ok( sz
== 9, "size wrong,(%i)\n",sz
);
530 ok( 0 == strcmp(buffer
,"[[2]] hey"), "wrong output (%s)\n",buffer
);
532 r
= MsiRecordSetStringA(hrec
, 0, "[[[3]]] [2]");
533 ok( r
== ERROR_SUCCESS
, "set string failed\n");
534 r
= MsiRecordSetStringA(hrec
, 1, "2");
535 ok( r
== ERROR_SUCCESS
, "set string failed\n");
536 r
= MsiRecordSetStringA(hrec
, 2, "hey");
537 ok( r
== ERROR_SUCCESS
, "set string failed\n");
538 r
= MsiRecordSetStringA(hrec
, 3, "1");
539 ok( r
== ERROR_SUCCESS
, "set string failed\n");
541 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
542 ok( r
== ERROR_SUCCESS
, "format failed\n");
543 ok( sz
== 7, "size wrong,(%i)\n",sz
);
544 ok( 0 == strcmp(buffer
,"hey hey"), "wrong output (%s)\n",buffer
);
546 r
= MsiCloseHandle(hrec
);
547 ok(r
==ERROR_SUCCESS
, "Unable to close record\n");
548 hrec
= MsiCreateRecord(12);
549 ok( hrec
, "failed to create record\n");
551 r
= MsiRecordSetStringA(hrec
, 0, "[[3][1]] [2]");
552 ok( r
== ERROR_SUCCESS
, "set string failed\n");
553 r
= MsiRecordSetStringA(hrec
, 1, "2");
554 ok( r
== ERROR_SUCCESS
, "set string failed\n");
555 r
= MsiRecordSetStringA(hrec
, 2, "hey");
556 ok( r
== ERROR_SUCCESS
, "set string failed\n");
557 r
= MsiRecordSetStringA(hrec
, 3, "1");
558 ok( r
== ERROR_SUCCESS
, "set string failed\n");
559 r
= MsiRecordSetStringA(hrec
, 12, "big");
560 ok( r
== ERROR_SUCCESS
, "set string failed\n");
562 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
563 ok( r
== ERROR_SUCCESS
, "format failed\n");
564 ok( sz
== 7, "size wrong,(%i)\n",sz
);
565 ok( 0 == strcmp(buffer
,"big hey"), "wrong output (%s)\n",buffer
);
567 r
= MsiRecordSetStringA(hrec
, 0, "[[3][4][1]] [2]");
568 ok( r
== ERROR_SUCCESS
, "set string failed\n");
569 r
= MsiRecordSetStringA(hrec
, 1, "2");
570 ok( r
== ERROR_SUCCESS
, "set string failed\n");
571 r
= MsiRecordSetStringA(hrec
, 2, "hey");
572 ok( r
== ERROR_SUCCESS
, "set string failed\n");
573 r
= MsiRecordSetStringA(hrec
, 3, "1");
574 ok( r
== ERROR_SUCCESS
, "set string failed\n");
575 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
576 ok( r
== ERROR_SUCCESS
, "set string failed\n");
577 r
= MsiRecordSetStringA(hrec
, 12, "big");
578 ok( r
== ERROR_SUCCESS
, "set string failed\n");
580 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
581 ok( r
== ERROR_SUCCESS
, "format failed\n");
582 ok( sz
== 7, "size wrong,(%i)\n",sz
);
583 ok( 0 == strcmp(buffer
,"big hey"), "wrong output (%s)\n",buffer
);
585 r
= MsiRecordSetStringA(hrec
, 0, "[[3][[4]][1]] [2]");
586 ok( r
== ERROR_SUCCESS
, "set string failed\n");
587 r
= MsiRecordSetStringA(hrec
, 1, "2");
588 ok( r
== ERROR_SUCCESS
, "set string failed\n");
589 r
= MsiRecordSetStringA(hrec
, 2, "hey");
590 ok( r
== ERROR_SUCCESS
, "set string failed\n");
591 r
= MsiRecordSetStringA(hrec
, 3, "1");
592 ok( r
== ERROR_SUCCESS
, "set string failed\n");
593 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
594 ok( r
== ERROR_SUCCESS
, "set string failed\n");
595 r
= MsiRecordSetStringA(hrec
, 12, "big");
596 ok( r
== ERROR_SUCCESS
, "set string failed\n");
598 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
599 ok( r
== ERROR_SUCCESS
, "format failed\n");
600 ok( sz
== 10, "size wrong,(%i)\n",sz
);
601 ok( 0 == strcmp(buffer
,"[1[]2] hey"), "wrong output (%s)\n",buffer
);
603 /* incorrect formats */
604 r
= MsiRecordSetStringA(hrec
, 0, "[[[3][[4]][1]] [2]");
605 ok( r
== ERROR_SUCCESS
, "set string failed\n");
606 r
= MsiRecordSetStringA(hrec
, 1, "2");
607 ok( r
== ERROR_SUCCESS
, "set string failed\n");
608 r
= MsiRecordSetStringA(hrec
, 2, "hey");
609 ok( r
== ERROR_SUCCESS
, "set string failed\n");
610 r
= MsiRecordSetStringA(hrec
, 3, "1");
611 ok( r
== ERROR_SUCCESS
, "set string failed\n");
612 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
613 ok( r
== ERROR_SUCCESS
, "set string failed\n");
614 r
= MsiRecordSetStringA(hrec
, 12, "big");
615 ok( r
== ERROR_SUCCESS
, "set string failed\n");
617 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
618 ok( r
== ERROR_SUCCESS
, "format failed\n");
619 ok( sz
== 18, "size wrong,(%i)\n",sz
);
620 ok( 0 == strcmp(buffer
,"[[[3][[4]][1]] [2]"), "wrong output (%s)\n",buffer
);
622 r
= MsiRecordSetStringA(hrec
, 0, "[[3][[4]][1]] [2]]");
623 ok( r
== ERROR_SUCCESS
, "set string failed\n");
624 r
= MsiRecordSetStringA(hrec
, 1, "2");
625 ok( r
== ERROR_SUCCESS
, "set string failed\n");
626 r
= MsiRecordSetStringA(hrec
, 2, "hey");
627 ok( r
== ERROR_SUCCESS
, "set string failed\n");
628 r
= MsiRecordSetStringA(hrec
, 3, "1");
629 ok( r
== ERROR_SUCCESS
, "set string failed\n");
630 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
631 ok( r
== ERROR_SUCCESS
, "set string failed\n");
632 r
= MsiRecordSetStringA(hrec
, 12, "big");
633 ok( r
== ERROR_SUCCESS
, "set string failed\n");
635 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
636 ok( r
== ERROR_SUCCESS
, "format failed\n");
637 ok( sz
== 11, "size wrong,(%i)\n",sz
);
638 ok( 0 == strcmp(buffer
,"[1[]2] hey]"), "wrong output (%s)\n",buffer
);
641 /* play games with {} */
643 r
= MsiRecordSetStringA(hrec
, 0, "{[3][1]} [2]");
644 ok( r
== ERROR_SUCCESS
, "set string failed\n");
645 r
= MsiRecordSetStringA(hrec
, 1, "2");
646 ok( r
== ERROR_SUCCESS
, "set string failed\n");
647 r
= MsiRecordSetStringA(hrec
, 2, "hey");
648 ok( r
== ERROR_SUCCESS
, "set string failed\n");
649 r
= MsiRecordSetStringA(hrec
, 3, "1");
650 ok( r
== ERROR_SUCCESS
, "set string failed\n");
651 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
652 ok( r
== ERROR_SUCCESS
, "set string failed\n");
653 r
= MsiRecordSetStringA(hrec
, 12, "big");
654 ok( r
== ERROR_SUCCESS
, "set string failed\n");
656 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
657 ok( r
== ERROR_SUCCESS
, "format failed\n");
658 ok( sz
== 6, "size wrong,(%i)\n",sz
);
659 ok( 0 == strcmp(buffer
,"12 hey"), "wrong output (%s)\n",buffer
);
661 r
= MsiRecordSetStringA(hrec
, 0, "[{[3][1]}] [2]");
662 ok( r
== ERROR_SUCCESS
, "set string failed\n");
663 r
= MsiRecordSetStringA(hrec
, 1, "2");
664 ok( r
== ERROR_SUCCESS
, "set string failed\n");
665 r
= MsiRecordSetStringA(hrec
, 2, "hey");
666 ok( r
== ERROR_SUCCESS
, "set string failed\n");
667 r
= MsiRecordSetStringA(hrec
, 3, "1");
668 ok( r
== ERROR_SUCCESS
, "set string failed\n");
669 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
670 ok( r
== ERROR_SUCCESS
, "set string failed\n");
671 r
= MsiRecordSetStringA(hrec
, 12, "big");
672 ok( r
== ERROR_SUCCESS
, "set string failed\n");
674 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
675 ok( r
== ERROR_SUCCESS
, "format failed\n");
676 ok( sz
== 8, "size wrong,(%i)\n",sz
);
677 ok( 0 == strcmp(buffer
,"[12] hey"), "wrong output (%s)\n",buffer
);
680 r
= MsiRecordSetStringA(hrec
, 0, "{test} [2]");
681 ok( r
== ERROR_SUCCESS
, "set string failed\n");
682 r
= MsiRecordSetStringA(hrec
, 1, "2");
683 ok( r
== ERROR_SUCCESS
, "set string failed\n");
684 r
= MsiRecordSetStringA(hrec
, 2, "hey");
685 ok( r
== ERROR_SUCCESS
, "set string failed\n");
686 r
= MsiRecordSetStringA(hrec
, 3, "1");
687 ok( r
== ERROR_SUCCESS
, "set string failed\n");
688 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
689 ok( r
== ERROR_SUCCESS
, "set string failed\n");
690 r
= MsiRecordSetStringA(hrec
, 12, "big");
691 ok( r
== ERROR_SUCCESS
, "set string failed\n");
693 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
694 ok( r
== ERROR_SUCCESS
, "format failed\n");
695 ok( sz
== 10, "size wrong,(%i)\n",sz
);
696 ok( 0 == strcmp(buffer
,"{test} hey"), "wrong output (%s)\n",buffer
);
698 r
= MsiRecordSetStringA(hrec
, 0, "{[test]} [2]");
699 ok( r
== ERROR_SUCCESS
, "set string failed\n");
700 r
= MsiRecordSetStringA(hrec
, 1, "2");
701 ok( r
== ERROR_SUCCESS
, "set string failed\n");
702 r
= MsiRecordSetStringA(hrec
, 2, "hey");
703 ok( r
== ERROR_SUCCESS
, "set string failed\n");
704 r
= MsiRecordSetStringA(hrec
, 3, "1");
705 ok( r
== ERROR_SUCCESS
, "set string failed\n");
706 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
707 ok( r
== ERROR_SUCCESS
, "set string failed\n");
708 r
= MsiRecordSetStringA(hrec
, 12, "big");
709 ok( r
== ERROR_SUCCESS
, "set string failed\n");
711 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
712 ok( r
== ERROR_SUCCESS
, "format failed\n");
713 ok( sz
== 12, "size wrong,(%i)\n",sz
);
714 ok( 0 == strcmp(buffer
,"{[test]} hey"), "wrong output (%s)\n",buffer
);
716 r
= MsiRecordSetStringA(hrec
, 0, "{[1][2][3][4]} [2]");
717 ok( r
== ERROR_SUCCESS
, "set string failed\n");
718 r
= MsiRecordSetStringA(hrec
, 1, "2");
719 ok( r
== ERROR_SUCCESS
, "set string failed\n");
720 r
= MsiRecordSetStringA(hrec
, 2, "hey");
721 ok( r
== ERROR_SUCCESS
, "set string failed\n");
722 r
= MsiRecordSetStringA(hrec
, 3, "1");
723 ok( r
== ERROR_SUCCESS
, "set string failed\n");
724 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
725 ok( r
== ERROR_SUCCESS
, "set string failed\n");
726 r
= MsiRecordSetStringA(hrec
, 12, "big");
727 ok( r
== ERROR_SUCCESS
, "set string failed\n");
729 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
730 ok( r
== ERROR_SUCCESS
, "format failed\n");
731 ok( sz
== 4, "size wrong,(%i)\n",sz
);
732 ok( 0 == strcmp(buffer
," hey"), "wrong output (%s)\n",buffer
);
734 r
= MsiRecordSetStringA(hrec
, 0, "{[1][2][3][dummy]} [2]");
735 ok( r
== ERROR_SUCCESS
, "set string failed\n");
736 r
= MsiRecordSetStringA(hrec
, 1, "2");
737 ok( r
== ERROR_SUCCESS
, "set string failed\n");
738 r
= MsiRecordSetStringA(hrec
, 2, "hey");
739 ok( r
== ERROR_SUCCESS
, "set string failed\n");
740 r
= MsiRecordSetStringA(hrec
, 3, "1");
741 ok( r
== ERROR_SUCCESS
, "set string failed\n");
742 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
743 ok( r
== ERROR_SUCCESS
, "set string failed\n");
744 r
= MsiRecordSetStringA(hrec
, 12, "big");
745 ok( r
== ERROR_SUCCESS
, "set string failed\n");
747 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
748 ok( r
== ERROR_SUCCESS
, "format failed\n");
749 ok( sz
== 18, "size wrong,(%i)\n",sz
);
750 ok( 0 == strcmp(buffer
,"{2hey1[dummy]} hey"), "wrong output (%s)\n",buffer
);
752 r
= MsiRecordSetStringA(hrec
, 0, "{[1][2][3][4][dummy]} [2]");
753 ok( r
== ERROR_SUCCESS
, "set string failed\n");
754 r
= MsiRecordSetStringA(hrec
, 1, "2");
755 ok( r
== ERROR_SUCCESS
, "set string failed\n");
756 r
= MsiRecordSetStringA(hrec
, 2, "hey");
757 ok( r
== ERROR_SUCCESS
, "set string failed\n");
758 r
= MsiRecordSetStringA(hrec
, 3, "1");
759 ok( r
== ERROR_SUCCESS
, "set string failed\n");
760 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
761 ok( r
== ERROR_SUCCESS
, "set string failed\n");
762 r
= MsiRecordSetStringA(hrec
, 12, "big");
763 ok( r
== ERROR_SUCCESS
, "set string failed\n");
765 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
766 ok( r
== ERROR_SUCCESS
, "format failed\n");
767 ok( sz
== 18, "size wrong,(%i)\n",sz
);
768 ok( 0 == strcmp(buffer
,"{2hey1[dummy]} hey"), "wrong output (%s)\n",buffer
);
770 r
= MsiRecordSetStringA(hrec
, 0, "{{[1][2]}[3][4][dummy]}");
771 ok( r
== ERROR_SUCCESS
, "set string failed\n");
772 r
= MsiRecordSetStringA(hrec
, 1, "2");
773 ok( r
== ERROR_SUCCESS
, "set string failed\n");
774 r
= MsiRecordSetStringA(hrec
, 2, "hey");
775 ok( r
== ERROR_SUCCESS
, "set string failed\n");
776 r
= MsiRecordSetStringA(hrec
, 3, "1");
777 ok( r
== ERROR_SUCCESS
, "set string failed\n");
778 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
779 ok( r
== ERROR_SUCCESS
, "set string failed\n");
780 r
= MsiRecordSetStringA(hrec
, 12, "big");
781 ok( r
== ERROR_SUCCESS
, "set string failed\n");
783 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
784 ok( r
== ERROR_SUCCESS
, "format failed\n");
785 ok( sz
== 16, "size wrong,(%i)\n",sz
);
786 ok( 0 == strcmp(buffer
,"{{2hey}1[dummy]}"), "wrong output (%s)\n",buffer
);
788 r
= MsiRecordSetStringA(hrec
, 0, "{{[1][2]}[3]{[4][dummy]}}");
789 ok( r
== ERROR_SUCCESS
, "set string failed\n");
790 r
= MsiRecordSetStringA(hrec
, 1, "2");
791 ok( r
== ERROR_SUCCESS
, "set string failed\n");
792 r
= MsiRecordSetStringA(hrec
, 2, "hey");
793 ok( r
== ERROR_SUCCESS
, "set string failed\n");
794 r
= MsiRecordSetStringA(hrec
, 3, "1");
795 ok( r
== ERROR_SUCCESS
, "set string failed\n");
796 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
797 ok( r
== ERROR_SUCCESS
, "set string failed\n");
798 r
= MsiRecordSetStringA(hrec
, 12, "big");
799 ok( r
== ERROR_SUCCESS
, "set string failed\n");
801 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
802 ok( r
== ERROR_SUCCESS
, "format failed\n");
803 ok( sz
== 0, "size wrong,(%i)\n",sz
);
804 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
806 r
= MsiRecordSetStringA(hrec
, 0, "{{[1][2]}[3]} {[1][2]}");
807 ok( r
== ERROR_SUCCESS
, "set string failed\n");
808 r
= MsiRecordSetStringA(hrec
, 1, "1");
809 ok( r
== ERROR_SUCCESS
, "set string failed\n");
810 r
= MsiRecordSetStringA(hrec
, 2, "2");
811 ok( r
== ERROR_SUCCESS
, "set string failed\n");
812 r
= MsiRecordSetStringA(hrec
, 3, "3");
813 ok( r
== ERROR_SUCCESS
, "set string failed\n");
814 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
815 ok( r
== ERROR_SUCCESS
, "set string failed\n");
816 r
= MsiRecordSetStringA(hrec
, 12, "big");
817 ok( r
== ERROR_SUCCESS
, "set string failed\n");
819 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
820 ok( r
== ERROR_SUCCESS
, "format failed\n");
821 ok( sz
== 12, "size wrong,(%i)\n",sz
);
822 ok( 0 == strcmp(buffer
,"{{12}3} {12}"), "wrong output (%s)\n",buffer
);
824 r
= MsiRecordSetStringA(hrec
, 0, "{[1][2]} {{[1][2]}[3]} {[1][2]}");
825 ok( r
== ERROR_SUCCESS
, "set string failed\n");
826 r
= MsiRecordSetStringA(hrec
, 1, "1");
827 ok( r
== ERROR_SUCCESS
, "set string failed\n");
828 r
= MsiRecordSetStringA(hrec
, 2, "2");
829 ok( r
== ERROR_SUCCESS
, "set string failed\n");
830 r
= MsiRecordSetStringA(hrec
, 3, "3");
831 ok( r
== ERROR_SUCCESS
, "set string failed\n");
832 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
833 ok( r
== ERROR_SUCCESS
, "set string failed\n");
834 r
= MsiRecordSetStringA(hrec
, 12, "big");
835 ok( r
== ERROR_SUCCESS
, "set string failed\n");
837 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
838 ok( r
== ERROR_SUCCESS
, "format failed\n");
839 ok( sz
== 15, "size wrong,(%i)\n",sz
);
840 ok( 0 == strcmp(buffer
,"12 {{12}3} {12}"), "wrong output (%s)\n",buffer
);
842 r
= MsiRecordSetStringA(hrec
, 0, "{[4]}{[1][2]} {{[1][2]}[3]} {[1][2]}");
843 ok( r
== ERROR_SUCCESS
, "set string failed\n");
844 r
= MsiRecordSetStringA(hrec
, 1, "1");
845 ok( r
== ERROR_SUCCESS
, "set string failed\n");
846 r
= MsiRecordSetStringA(hrec
, 2, "2");
847 ok( r
== ERROR_SUCCESS
, "set string failed\n");
848 r
= MsiRecordSetStringA(hrec
, 3, "3");
849 ok( r
== ERROR_SUCCESS
, "set string failed\n");
850 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
851 ok( r
== ERROR_SUCCESS
, "set string failed\n");
852 r
= MsiRecordSetStringA(hrec
, 12, "big");
853 ok( r
== ERROR_SUCCESS
, "set string failed\n");
855 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
856 ok( r
== ERROR_SUCCESS
, "format failed\n");
857 ok( sz
== 15, "size wrong,(%i)\n",sz
);
858 ok( 0 == strcmp(buffer
,"12 {{12}3} {12}"), "wrong output (%s)\n",buffer
);
860 r
= MsiRecordSetStringA(hrec
, 0, "{blah} {[4]}{[1][2]} {{[1][2]}[3]} {[1][2]}");
861 ok( r
== ERROR_SUCCESS
, "set string failed\n");
862 r
= MsiRecordSetStringA(hrec
, 1, "1");
863 ok( r
== ERROR_SUCCESS
, "set string failed\n");
864 r
= MsiRecordSetStringA(hrec
, 2, "2");
865 ok( r
== ERROR_SUCCESS
, "set string failed\n");
866 r
= MsiRecordSetStringA(hrec
, 3, "3");
867 ok( r
== ERROR_SUCCESS
, "set string failed\n");
868 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
869 ok( r
== ERROR_SUCCESS
, "set string failed\n");
870 r
= MsiRecordSetStringA(hrec
, 12, "big");
871 ok( r
== ERROR_SUCCESS
, "set string failed\n");
873 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
874 ok( r
== ERROR_SUCCESS
, "format failed\n");
875 ok( sz
== 22, "size wrong,(%i)\n",sz
);
876 ok( 0 == strcmp(buffer
,"{blah} 12 {{12}3} {12}"), "wrong output (%s)\n",buffer
);
878 r
= MsiRecordSetStringA(hrec
, 0, "{{[1]}[2]} {[4]}{[1][2]}");
879 ok( r
== ERROR_SUCCESS
, "set string failed\n");
880 r
= MsiRecordSetStringA(hrec
, 1, "1");
881 ok( r
== ERROR_SUCCESS
, "set string failed\n");
882 r
= MsiRecordSetStringA(hrec
, 2, "2");
883 ok( r
== ERROR_SUCCESS
, "set string failed\n");
884 r
= MsiRecordSetStringA(hrec
, 3, "3");
885 ok( r
== ERROR_SUCCESS
, "set string failed\n");
886 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
887 ok( r
== ERROR_SUCCESS
, "set string failed\n");
888 r
= MsiRecordSetStringA(hrec
, 12, "big");
889 ok( r
== ERROR_SUCCESS
, "set string failed\n");
891 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
892 ok( r
== ERROR_SUCCESS
, "format failed\n");
893 ok( sz
== 13, "size wrong,(%i)\n",sz
);
894 ok( 0 == strcmp(buffer
,"{{1}2} {}{12}"), "wrong output (%s)\n",buffer
);
896 r
= MsiRecordSetStringA(hrec
, 0, "{{[1]}} {[4]}{[1][2]}");
897 ok( r
== ERROR_SUCCESS
, "set string failed\n");
898 r
= MsiRecordSetStringA(hrec
, 1, "1");
899 ok( r
== ERROR_SUCCESS
, "set string failed\n");
900 r
= MsiRecordSetStringA(hrec
, 2, "2");
901 ok( r
== ERROR_SUCCESS
, "set string failed\n");
902 r
= MsiRecordSetStringA(hrec
, 3, "3");
903 ok( r
== ERROR_SUCCESS
, "set string failed\n");
904 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
905 ok( r
== ERROR_SUCCESS
, "set string failed\n");
906 r
= MsiRecordSetStringA(hrec
, 12, "big");
907 ok( r
== ERROR_SUCCESS
, "set string failed\n");
909 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
910 ok( r
== ERROR_SUCCESS
, "format failed\n");
911 ok( sz
== 3, "size wrong,(%i)\n",sz
);
912 ok( 0 == strcmp(buffer
," 12"), "wrong output (%s)\n",buffer
);
914 r
= MsiRecordSetStringA(hrec
, 0, "{{{[1]}} {[4]}{[1][2]}");
915 ok( r
== ERROR_SUCCESS
, "set string failed\n");
916 r
= MsiRecordSetStringA(hrec
, 1, "1");
917 ok( r
== ERROR_SUCCESS
, "set string failed\n");
918 r
= MsiRecordSetStringA(hrec
, 2, "2");
919 ok( r
== ERROR_SUCCESS
, "set string failed\n");
920 r
= MsiRecordSetStringA(hrec
, 3, "3");
921 ok( r
== ERROR_SUCCESS
, "set string failed\n");
922 r
= MsiRecordSetStringA(hrec
, 4, NULL
);
923 ok( r
== ERROR_SUCCESS
, "set string failed\n");
924 r
= MsiRecordSetStringA(hrec
, 12, "big");
925 ok( r
== ERROR_SUCCESS
, "set string failed\n");
927 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
928 ok( r
== ERROR_SUCCESS
, "format failed\n");
930 ok( sz
== 3, "size wrong,(%i)\n",sz
);
931 ok( 0 == strcmp(buffer
," 12"), "wrong output (%s)\n",buffer
);
934 /* now put play games with escaping */
935 r
= MsiRecordSetStringA(hrec
, 0, "[1] [2] [\\3asdf]");
936 ok( r
== ERROR_SUCCESS
, "set string failed\n");
937 r
= MsiRecordSetStringA(hrec
, 1, "boo");
938 ok( r
== ERROR_SUCCESS
, "set string failed\n");
939 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
940 ok( r
== ERROR_SUCCESS
, "set string failed\n");
942 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
943 ok( r
== ERROR_SUCCESS
, "format failed\n");
944 ok( sz
== 16, "size wrong\n");
945 ok( 0 == strcmp(buffer
,"boo hoo [\\3asdf]"), "wrong output\n");
947 /* now put play games with escaping */
948 r
= MsiRecordSetStringA(hrec
, 0, "[1] [2] [\\x]");
949 ok( r
== ERROR_SUCCESS
, "set string failed\n");
950 r
= MsiRecordSetStringA(hrec
, 1, "boo");
951 ok( r
== ERROR_SUCCESS
, "set string failed\n");
952 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
953 ok( r
== ERROR_SUCCESS
, "set string failed\n");
955 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
956 ok( r
== ERROR_SUCCESS
, "format failed\n");
957 ok( sz
== 12, "size wrong\n");
958 ok( 0 == strcmp(buffer
,"boo hoo [\\x]"), "wrong output\n");
960 r
= MsiRecordSetStringA(hrec
, 0, "[\\x]");
961 ok( r
== ERROR_SUCCESS
, "set string failed\n");
963 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
964 ok( r
== ERROR_SUCCESS
, "format failed\n");
965 ok( sz
== 4, "size wrong: %d\n", sz
);
966 ok( 0 == strcmp(buffer
,"[\\x]"), "wrong output: %s\n", buffer
);
968 r
= MsiRecordSetStringA(hrec
, 0, "{\\x}");
969 ok( r
== ERROR_SUCCESS
, "set string failed\n");
971 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
972 ok( r
== ERROR_SUCCESS
, "format failed\n");
973 ok( sz
== 4, "size wrong: %d\n", sz
);
974 ok( 0 == strcmp(buffer
,"{\\x}"), "wrong output: %s\n", buffer
);
976 r
= MsiRecordSetStringA(hrec
, 0, "[abc\\x]");
977 ok( r
== ERROR_SUCCESS
, "set string failed\n");
979 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
980 ok( r
== ERROR_SUCCESS
, "format failed\n");
981 ok( sz
== 7, "size wrong: %d\n", sz
);
982 ok( 0 == strcmp(buffer
,"[abc\\x]"), "wrong output: %s\n", buffer
);
984 r
= MsiRecordSetStringA(hrec
, 0, "[\\[]Bracket Text[\\]]");
985 ok( r
== ERROR_SUCCESS
, "set string failed\n");
987 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
988 ok( r
== ERROR_SUCCESS
, "format failed\n");
989 ok( sz
== 20, "size wrong: %d\n", sz
);
990 ok( 0 == strcmp(buffer
,"[\\[]Bracket Text[\\]]"), "wrong output: %s\n", buffer
);
992 /* now try other formats without a package */
993 r
= MsiRecordSetStringA(hrec
, 0, "[1] [2] [property]");
994 ok( r
== ERROR_SUCCESS
, "set string failed\n");
995 r
= MsiRecordSetStringA(hrec
, 1, "boo");
996 ok( r
== ERROR_SUCCESS
, "set string failed\n");
997 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
998 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1000 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1001 ok( r
== ERROR_SUCCESS
, "format failed\n");
1002 ok( sz
== 18, "size wrong\n");
1003 ok( 0 == strcmp(buffer
,"boo hoo [property]"), "wrong output\n");
1005 r
= MsiRecordSetStringA(hrec
, 0, "[1] [~] [2]");
1006 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1007 r
= MsiRecordSetStringA(hrec
, 1, "boo");
1008 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1009 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
1010 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1012 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1013 ok( r
== ERROR_SUCCESS
, "format failed\n");
1014 ok( sz
== 11, "size wrong\n");
1015 ok( 0 == strcmp(buffer
,"boo [~] hoo"), "wrong output (%s)\n",buffer
);
1017 r
= MsiRecordSetStringA(hrec
, 0, "[1]");
1018 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1019 r
= MsiRecordSetInteger(hrec
, 1, 123456);
1020 ok( r
== ERROR_SUCCESS
, "set integer failed\n");
1022 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1023 ok( r
== ERROR_SUCCESS
, "format failed\n");
1024 ok( sz
== 6, "size wrong\n");
1025 ok( 0 == strcmp(buffer
,"123456"), "wrong output (%s)\n",buffer
);
1027 r
= MsiRecordSetStringA(hrec
, 0, "[~]");
1028 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1030 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1031 ok( sz
== 3, "size wrong\n");
1032 ok( 0 == strcmp(buffer
,"[~]"), "wrong output\n");
1033 ok( r
== ERROR_SUCCESS
, "format failed\n");
1035 r
= MsiRecordSetStringA(hrec
, 0, "[]");
1036 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1038 r
= MsiFormatRecordA(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 /* MsiFormatRecordA doesn't seem to handle a negative too well */
1044 r
= MsiRecordSetStringA(hrec
, 0, "[-1]");
1045 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1047 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1048 ok( sz
== 4, "size wrong\n");
1049 ok( 0 == strcmp(buffer
,"[-1]"), "wrong output\n");
1050 ok( r
== ERROR_SUCCESS
, "format failed\n");
1052 r
= MsiRecordSetStringA(hrec
, 0, "{[]}");
1053 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1055 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1056 ok( sz
== 4, "size wrong\n");
1057 ok( 0 == strcmp(buffer
,"{[]}"), "wrong output\n");
1058 ok( r
== ERROR_SUCCESS
, "format failed\n");
1060 r
= MsiRecordSetStringA(hrec
, 0, "[0]");
1061 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1063 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1064 ok( sz
== 3, "size wrong\n");
1065 ok( 0 == strcmp(buffer
,"[0]"), "wrong output\n");
1066 ok( r
== ERROR_SUCCESS
, "format failed\n");
1068 r
= MsiRecordSetStringA(hrec
, 0, "[100]");
1069 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1071 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1072 ok( sz
== 0, "size wrong\n");
1073 ok( 0 == strcmp(buffer
,""), "wrong output\n");
1074 ok( r
== ERROR_SUCCESS
, "format failed\n");
1076 r
= MsiRecordSetStringA(hrec
, 0, "{[1] [2]}");
1077 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1078 r
= MsiRecordSetStringA(hrec
, 1, "boo");
1079 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1080 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
1081 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1083 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1084 ok( sz
== 7, "size wrong\n");
1085 ok( 0 == strcmp(buffer
,"boo hoo"), "wrong output\n");
1086 ok( r
== ERROR_SUCCESS
, "format failed\n");
1088 r
= MsiRecordSetStringA(hrec
, 0, "{}");
1089 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1091 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1092 ok( sz
== 0, "size wrong\n");
1093 ok( 0 == strcmp(buffer
,""), "wrong output\n");
1094 ok( r
== ERROR_SUCCESS
, "format failed\n");
1096 r
= MsiRecordSetStringA(hrec
, 0, "{foo}");
1097 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1099 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1100 ok( sz
== 5, "size wrong\n");
1101 ok( 0 == strcmp(buffer
,"{foo}"), "wrong output\n");
1102 ok( r
== ERROR_SUCCESS
, "format failed\n");
1104 r
= MsiRecordSetStringA(hrec
, 0, "{boo [1]}");
1105 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1106 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1107 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1109 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1110 ok( sz
== 7, "size wrong\n");
1111 ok( 0 == strcmp(buffer
,"boo hoo"), "wrong output\n");
1112 ok( r
== ERROR_SUCCESS
, "format failed\n");
1114 r
= MsiRecordSetStringA(hrec
, 0, "{{[1]}}");
1115 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1116 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1117 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1119 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1120 ok( sz
== 0, "size wrong\n");
1121 ok( 0 == strcmp(buffer
,""), "wrong output\n");
1122 ok( r
== ERROR_SUCCESS
, "format failed\n");
1124 r
= MsiRecordSetStringA(hrec
, 0, "{ {[1]}}");
1125 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1126 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1127 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1129 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1132 ok( 0 == strcmp(buffer
," {hoo}"), "wrong output\n");
1133 ok( sz
== 6, "size wrong\n");
1135 ok( r
== ERROR_SUCCESS
, "format failed\n");
1137 r
= MsiRecordSetStringA(hrec
, 0, "{{[1]} }");
1138 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1139 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1140 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1142 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1143 ok( sz
== 8, "size wrong\n");
1144 ok( 0 == strcmp(buffer
,"{{hoo} }"), "wrong output\n");
1145 ok( r
== ERROR_SUCCESS
, "format failed\n");
1147 r
= MsiRecordSetStringA(hrec
, 0, "{{ [1]}}");
1148 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1149 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1150 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1152 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1153 ok( sz
== 0, "size wrong\n");
1154 ok( 0 == strcmp(buffer
,""), "wrong output\n");
1155 ok( r
== ERROR_SUCCESS
, "format failed\n");
1157 r
= MsiRecordSetStringA(hrec
, 0, "{{[1] }}");
1158 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1159 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1160 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1162 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1163 ok( sz
== 0, "size wrong\n");
1164 ok( 0 == strcmp(buffer
,""), "wrong output\n");
1165 ok( r
== ERROR_SUCCESS
, "format failed\n");
1167 r
= MsiRecordSetStringA(hrec
, 0, "{{a}{b}{c }{ d}{any text}}");
1168 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1170 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1171 ok( sz
== 0, "size wrong\n");
1172 ok( 0 == strcmp(buffer
,""), "wrong output\n");
1173 ok( r
== ERROR_SUCCESS
, "format failed\n");
1175 r
= MsiRecordSetStringA(hrec
, 0, "{{a} }");
1176 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1178 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1179 ok( sz
== 6, "size wrong\n");
1180 ok( 0 == strcmp(buffer
,"{{a} }"), "wrong output\n");
1181 ok( r
== ERROR_SUCCESS
, "format failed\n");
1183 r
= MsiRecordSetStringA(hrec
, 0, "{{a} {b}}");
1184 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1186 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1187 ok( sz
== 0, "size wrong\n");
1188 ok( 0 == strcmp(buffer
,""), "wrong output\n");
1189 ok( r
== ERROR_SUCCESS
, "format failed\n");
1191 r
= MsiRecordSetStringA(hrec
, 0, "{{a} b}}");
1192 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1194 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1195 todo_wine
ok( sz
== 0, "size wrong\n");
1196 todo_wine
ok( 0 == strcmp(buffer
,""), "wrong output\n");
1197 ok( r
== ERROR_SUCCESS
, "format failed\n");
1199 r
= MsiRecordSetStringA(hrec
, 0, "{{a b}}");
1200 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1202 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1203 ok( sz
== 0, "size wrong\n");
1204 ok( 0 == strcmp(buffer
,""), "wrong output\n");
1205 ok( r
== ERROR_SUCCESS
, "format failed\n");
1207 r
= MsiRecordSetStringA(hrec
, 0, "{ }");
1208 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1210 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1211 ok( sz
== 3, "size wrong\n");
1212 ok( 0 == strcmp(buffer
,"{ }"), "wrong output\n");
1213 ok( r
== ERROR_SUCCESS
, "format failed\n");
1215 r
= MsiRecordSetStringA(hrec
, 0, " {{a}}}");
1216 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1218 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1219 ok( sz
== 2, "size wrong\n");
1220 ok( 0 == strcmp(buffer
," }"), "wrong output\n");
1221 ok( r
== ERROR_SUCCESS
, "format failed\n");
1223 r
= MsiRecordSetStringA(hrec
, 0, "{{ almost {{ any }} text }}");
1224 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1226 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1227 todo_wine
ok( sz
== 8, "size wrong\n");
1228 todo_wine
ok( 0 == strcmp(buffer
," text }}"), "wrong output\n");
1229 ok( r
== ERROR_SUCCESS
, "format failed\n");
1231 r
= MsiRecordSetStringA(hrec
, 0, "{{ } { hidden ][ [ }}");
1232 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1234 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1235 todo_wine
ok( sz
== 0, "size wrong\n");
1236 todo_wine
ok( 0 == strcmp(buffer
,""), "wrong output\n");
1237 ok( r
== ERROR_SUCCESS
, "format failed\n");
1239 r
= MsiRecordSetStringA(hrec
, 0, "[ 1]");
1240 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1241 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1242 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1244 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1245 ok( sz
== 4, "size wrong\n");
1246 ok( 0 == strcmp(buffer
,"[ 1]"), "wrong output\n");
1247 ok( r
== ERROR_SUCCESS
, "format failed\n");
1249 r
= MsiRecordSetStringA(hrec
, 0, "[01]");
1250 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1251 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1252 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1254 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1255 ok( sz
== 3, "size wrong\n");
1256 ok( 0 == strcmp(buffer
,"hoo"), "wrong output\n");
1257 ok( r
== ERROR_SUCCESS
, "format failed\n");
1259 r
= MsiRecordSetStringA(hrec
, 0, "{{test}} [01");
1260 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1261 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1262 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1264 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1265 todo_wine
ok( sz
== 4, "size wrong\n");
1266 todo_wine
ok( 0 == strcmp(buffer
," [01"), "wrong output\n");
1267 ok( r
== ERROR_SUCCESS
, "format failed\n");
1269 r
= MsiRecordSetStringA(hrec
, 0, "[\\[]");
1270 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1271 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1272 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1274 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1275 ok( sz
== 4, "size wrong\n");
1276 ok( 0 == strcmp(buffer
,"[\\[]"), "wrong output\n");
1277 ok( r
== ERROR_SUCCESS
, "format failed\n");
1279 r
= MsiRecordSetStringA(hrec
, 0, "[\\[]");
1280 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1281 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1282 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1283 sz
= sizeof(buffer
);
1284 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1285 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1286 ok(sz
== 4, "Expected 4, got %d\n", sz
);
1287 ok(!lstrcmpA(buffer
, "[\\[]"), "Expected \"[\\[]\", got \"%s\"\n", buffer
);
1289 r
= MsiRecordSetStringA(hrec
, 0, "[foo]");
1290 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1291 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1292 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1294 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1295 ok( sz
== 5, "size wrong\n");
1296 ok( 0 == strcmp(buffer
,"[foo]"), "wrong output\n");
1297 ok( r
== ERROR_SUCCESS
, "format failed\n");
1299 r
= MsiRecordSetStringA(hrec
, 0, "[01.]");
1300 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1301 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1302 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1304 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1305 ok( sz
== 5, "size wrong\n");
1306 ok( 0 == strcmp(buffer
,"[01.]"), "wrong output\n");
1307 ok( r
== ERROR_SUCCESS
, "format failed\n");
1309 SetEnvironmentVariableA("FOO", "BAR");
1310 r
= MsiRecordSetStringA(hrec
, 0, "[%FOO]");
1311 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1313 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1314 ok( sz
== 6, "size wrong\n");
1315 ok( 0 == strcmp(buffer
,"[%FOO]"), "wrong output\n");
1316 ok( r
== ERROR_SUCCESS
, "format failed\n");
1318 r
= MsiRecordSetStringA(hrec
, 0, "{{[1]}");
1319 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1320 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1321 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1323 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1324 ok( sz
== 6, "size wrong\n");
1325 ok( 0 == strcmp(buffer
,"{{hoo}"), "wrong output\n");
1326 ok( r
== ERROR_SUCCESS
, "format failed\n");
1328 r
= MsiRecordSetStringA(hrec
, 0, "{{ {[1]}");
1329 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1330 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1331 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1333 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1334 ok( sz
== 8, "size wrong\n");
1335 ok( 0 == strcmp(buffer
,"{{ {hoo}"), "wrong output\n");
1336 ok( r
== ERROR_SUCCESS
, "format failed\n");
1338 r
= MsiRecordSetStringA(hrec
, 0, "{{ {[1]}");
1339 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1340 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1341 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1343 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1344 ok( sz
== 8, "size wrong\n");
1345 ok( 0 == strcmp(buffer
,"{{ {hoo}"), "wrong output\n");
1346 ok( r
== ERROR_SUCCESS
, "format failed\n");
1348 r
= MsiRecordSetStringA(hrec
, 0, "{{ {{[1]}");
1349 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1350 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1351 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1353 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1354 ok( sz
== 9, "size wrong\n");
1355 ok( 0 == strcmp(buffer
,"{{ {{hoo}"), "wrong output\n");
1356 ok( r
== ERROR_SUCCESS
, "format failed\n");
1358 r
= MsiRecordSetStringA(hrec
, 0, "[1]}");
1359 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1360 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1361 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1363 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1364 ok( sz
== 4, "size wrong\n");
1365 ok( 0 == strcmp(buffer
,"hoo}"), "wrong output\n");
1366 ok( r
== ERROR_SUCCESS
, "format failed\n");
1368 r
= MsiRecordSetStringA(hrec
, 0, "{{ {{a}");
1369 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1371 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1372 ok( sz
== 7, "size wrong\n");
1373 ok( 0 == strcmp(buffer
,"{{ {{a}"), "wrong output\n");
1374 ok( r
== ERROR_SUCCESS
, "format failed\n");
1376 r
= MsiRecordSetStringA(hrec
, 0, "{{ {{a}");
1377 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1379 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1380 ok( sz
== 7, "size wrong\n");
1381 ok( 0 == strcmp(buffer
,"{{ {{a}"), "wrong output\n");
1382 ok( r
== ERROR_SUCCESS
, "format failed\n");
1384 r
= MsiRecordSetStringA(hrec
, 0, "0{1{2{3{4[1]5}6}7}8}9");
1385 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1386 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1387 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1389 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1392 ok( sz
== 19, "size wrong\n");
1393 ok( 0 == strcmp(buffer
,"01{2{3{4hoo56}7}8}9"), "wrong output\n");
1395 ok( r
== ERROR_SUCCESS
, "format failed\n");
1397 r
= MsiRecordSetStringA(hrec
, 0, "0{1{2[1]3}4");
1398 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1399 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1400 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1402 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1405 ok( sz
== 9, "size wrong\n");
1406 ok( 0 == strcmp(buffer
,"01{2hoo34"), "wrong output\n");
1408 ok( r
== ERROR_SUCCESS
, "format failed\n");
1410 r
= MsiRecordSetStringA(hrec
, 0, "0{1{2[1]3}4");
1411 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1412 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1413 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1415 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1418 ok( sz
== 9, "size wrong\n");
1419 ok( 0 == strcmp(buffer
,"01{2hoo34"), "wrong output\n");
1421 ok( r
== ERROR_SUCCESS
, "format failed\n");
1423 r
= MsiRecordSetStringA(hrec
, 0, "{[1.} [1]");
1424 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1425 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1426 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1428 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1429 ok( sz
== 9, "size wrong\n");
1432 ok( 0 == strcmp(buffer
,"{[1.} hoo"), "wrong output\n");
1434 ok( r
== ERROR_SUCCESS
, "format failed\n");
1436 r
= MsiRecordSetStringA(hrec
, 0, "{[{[1]}]}");
1437 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1438 r
= MsiRecordSetStringA(hrec
, 1, "2");
1439 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1440 r
= MsiRecordSetStringA(hrec
, 2, "foo");
1441 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1443 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1446 ok( sz
== 9, "size wrong\n");
1447 ok( 0 == strcmp(buffer
,"{[{[1]}]}"), "wrong output\n");
1449 ok( r
== ERROR_SUCCESS
, "format failed\n");
1451 r
= MsiRecordSetStringA(hrec
, 0, "{[1][}");
1452 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1453 r
= MsiRecordSetStringA(hrec
, 1, "2");
1454 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1455 r
= MsiRecordSetStringA(hrec
, 2, "foo");
1456 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1458 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1461 ok( sz
== 2, "size wrong\n");
1462 ok( 0 == strcmp(buffer
,"2["), "wrong output\n");
1464 ok( r
== ERROR_SUCCESS
, "format failed\n");
1466 r
= MsiRecordSetStringA(hrec
, 0, "[1]");
1467 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1468 r
= MsiRecordSetStringA(hrec
, 1, "[2]");
1469 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1470 r
= MsiRecordSetStringA(hrec
, 2, "foo");
1471 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1473 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1474 ok( sz
== 3, "size wrong\n");
1475 ok( 0 == strcmp(buffer
,"[2]"), "wrong output\n");
1476 ok( r
== ERROR_SUCCESS
, "format failed\n");
1478 r
= MsiRecordSetStringA(hrec
, 0, "[{{boo}}1]");
1479 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1480 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1481 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1483 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1484 ok( r
== ERROR_SUCCESS
, "format failed\n");
1485 ok( sz
== 3, "size wrong\n");
1488 ok( 0 == strcmp(buffer
,"[1]"), "wrong output: %s\n", buffer
);
1491 r
= MsiRecordSetStringA(hrec
, 0, "[{{boo}}1]");
1492 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1493 r
= MsiRecordSetStringA(hrec
, 0, "[1{{boo}}]");
1494 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1495 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1496 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1498 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1499 ok( sz
== 3, "size wrong\n");
1500 ok( 0 == strcmp(buffer
,"[1]"), "wrong output\n");
1501 ok( r
== ERROR_SUCCESS
, "format failed\n");
1503 r
= MsiRecordSetStringA(hrec
, 0, "{[1]{{boo} }}");
1504 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1505 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1506 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1508 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1511 ok( sz
== 11, "size wrong\n");
1512 ok( 0 == strcmp(buffer
,"hoo{{boo }}"), "wrong output\n");
1514 ok( r
== ERROR_SUCCESS
, "format failed\n");
1516 r
= MsiRecordSetStringA(hrec
, 0, "{[1{{boo}}]}");
1517 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1518 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1519 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1521 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1524 ok( sz
== 12, "size wrong: got %u, expected 12\n", sz
);
1525 ok( 0 == strcmp(buffer
,"{[1{{boo}}]}"), "wrong output: got %s, expected [1]\n", buffer
);
1527 ok( r
== ERROR_SUCCESS
, "format failed\n");
1529 r
= MsiRecordSetStringA(hrec
, 0, "{{[1]}");
1530 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1531 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1532 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1534 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1535 ok( sz
== 6, "size wrong: got %u, expected 3\n", sz
);
1536 ok( 0 == strcmp(buffer
,"{{hoo}"), "wrong output: got %s, expected [1]\n", buffer
);
1537 ok( r
== ERROR_SUCCESS
, "format failed\n");
1539 r
= MsiRecordSetStringA(hrec
, 0, "{[1{{bo}o}}]}");
1540 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1541 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1542 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1544 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1545 ok( sz
== 13, "size wrong\n");
1546 ok( 0 == strcmp(buffer
,"{[1{{bo}o}}]}"), "wrong output %s\n",buffer
);
1547 ok( r
== ERROR_SUCCESS
, "format failed\n");
1549 r
= MsiRecordSetStringA(hrec
, 0, "{[1{{b{o}o}}]}");
1550 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1552 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1555 ok( sz
== 14, "size wrong\n");
1556 ok( 0 == strcmp(buffer
,"{[1{{b{o}o}}]}"), "wrong output %s\n",buffer
);
1558 ok( r
== ERROR_SUCCESS
, "format failed\n");
1560 r
= MsiRecordSetStringA(hrec
, 0, "{ {[1]}");
1561 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1562 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
1563 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1565 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1568 ok( sz
== 5, "size wrong\n");
1569 ok( 0 == strcmp(buffer
," {hoo"), "wrong output %s\n",buffer
);
1571 ok( r
== ERROR_SUCCESS
, "format failed\n");
1573 /* {} inside a substitution does strange things... */
1574 r
= MsiRecordSetStringA(hrec
, 0, "[[1]{}]");
1575 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1576 r
= MsiRecordSetStringA(hrec
, 1, "2");
1577 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1579 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1582 ok( sz
== 5, "size wrong\n");
1583 ok( 0 == strcmp(buffer
,"[[1]]"), "wrong output %s\n",buffer
);
1585 ok( r
== ERROR_SUCCESS
, "format failed\n");
1587 r
= MsiRecordSetStringA(hrec
, 0, "[[1]{}[1]]");
1588 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1589 r
= MsiRecordSetStringA(hrec
, 1, "2");
1590 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1592 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1595 ok( sz
== 6, "size wrong\n");
1596 ok( 0 == strcmp(buffer
,"[[1]2]"), "wrong output %s\n",buffer
);
1598 ok( r
== ERROR_SUCCESS
, "format failed\n");
1600 r
= MsiRecordSetStringA(hrec
, 0, "[a[1]b[1]c{}d[1]e]");
1601 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1602 r
= MsiRecordSetStringA(hrec
, 1, "2");
1603 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1605 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1608 ok( sz
== 14, "size wrong\n");
1609 ok( 0 == strcmp(buffer
,"[a[1]b[1]cd2e]"), "wrong output %s\n",buffer
);
1611 ok( r
== ERROR_SUCCESS
, "format failed\n");
1613 r
= MsiRecordSetStringA(hrec
, 0, "[a[1]b");
1614 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1615 r
= MsiRecordSetStringA(hrec
, 1, "2");
1616 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1618 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1619 ok( sz
== 6, "size wrong\n");
1620 ok( 0 == strcmp(buffer
,"[a[1]b"), "wrong output %s\n",buffer
);
1621 ok( r
== ERROR_SUCCESS
, "format failed\n");
1623 r
= MsiRecordSetStringA(hrec
, 0, "a[1]b]");
1624 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1625 r
= MsiRecordSetStringA(hrec
, 1, "2");
1626 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1628 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1629 ok( sz
== 4, "size wrong\n");
1630 ok( 0 == strcmp(buffer
,"a2b]"), "wrong output %s\n",buffer
);
1631 ok( r
== ERROR_SUCCESS
, "format failed\n");
1633 r
= MsiRecordSetStringA(hrec
, 0, "]a[1]b");
1634 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1635 r
= MsiRecordSetStringA(hrec
, 1, "2");
1636 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1638 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1639 ok( sz
== 4, "size wrong\n");
1640 ok( 0 == strcmp(buffer
,"]a2b"), "wrong output %s\n",buffer
);
1641 ok( r
== ERROR_SUCCESS
, "format failed\n");
1643 r
= MsiRecordSetStringA(hrec
, 0, "]a[1]b");
1644 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1645 r
= MsiRecordSetStringA(hrec
, 1, "2");
1646 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1648 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1649 ok( sz
== 4, "size wrong\n");
1650 ok( 0 == strcmp(buffer
,"]a2b"), "wrong output %s\n",buffer
);
1651 ok( r
== ERROR_SUCCESS
, "format failed\n");
1653 r
= MsiRecordSetStringA(hrec
, 0, "\\[1]");
1654 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1655 r
= MsiRecordSetStringA(hrec
, 1, "2");
1656 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1658 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1659 ok( sz
== 2, "size wrong\n");
1660 ok( 0 == strcmp(buffer
,"\\2"), "wrong output %s\n",buffer
);
1661 ok( r
== ERROR_SUCCESS
, "format failed\n");
1663 r
= MsiRecordSetStringA(hrec
, 0, "\\{[1]}");
1664 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1665 r
= MsiRecordSetStringA(hrec
, 1, "2");
1666 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1668 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1669 ok( sz
== 2, "size wrong\n");
1670 ok( 0 == strcmp(buffer
,"\\2"), "wrong output %s\n",buffer
);
1671 ok( r
== ERROR_SUCCESS
, "format failed\n");
1673 r
= MsiRecordSetStringA(hrec
, 0, "a{b[1]c}d");
1674 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1675 r
= MsiRecordSetStringA(hrec
, 1, NULL
);
1676 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1678 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1679 ok( sz
== 2, "size wrong\n");
1680 ok( 0 == strcmp(buffer
,"ad"), "wrong output %s\n",buffer
);
1681 ok( r
== ERROR_SUCCESS
, "format failed\n");
1683 r
= MsiRecordSetStringA(hrec
, 0, "{a[0]b}");
1684 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1685 r
= MsiRecordSetStringA(hrec
, 1, "foo");
1686 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1688 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1689 ok( sz
== 9, "size wrong\n");
1690 ok( 0 == strcmp(buffer
,"a{a[0]b}b"), "wrong output %s\n",buffer
);
1691 ok( r
== ERROR_SUCCESS
, "format failed\n");
1693 r
= MsiRecordSetStringA(hrec
, 0, "[foo]");
1694 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1696 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1697 ok( sz
== 5, "size wrong\n");
1698 ok( 0 == strcmp(buffer
,"[foo]"), "wrong output %s\n",buffer
);
1699 ok( r
== ERROR_SUCCESS
, "format failed\n");
1701 r
= MsiRecordSetStringA(hrec
, 0, "{[1][-1][1]}");
1702 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1703 r
= MsiRecordSetStringA(hrec
, 1, "foo");
1704 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1706 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1709 ok( sz
== 12, "size wrong\n");
1710 ok( 0 == strcmp(buffer
,"{foo[-1]foo}"), "wrong output %s\n",buffer
);
1712 ok( r
== ERROR_SUCCESS
, "format failed\n");
1716 r
= MsiRecordSetStringA(hrec
, 0, "{abcd}");
1717 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1718 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1719 ok( r
== ERROR_SUCCESS
, "format failed\n");
1720 ok( sz
== 6, "size wrong(%i)\n",sz
);
1721 ok( 0 == strcmp(buffer
,"{abcd}"), "wrong output (%s)\n",buffer
);
1724 r
= MsiRecordSetStringA(hrec
, 0, "{a[one]bc[two]de[one]f}");
1725 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1726 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1727 ok( r
== ERROR_SUCCESS
, "format failed\n");
1728 ok( sz
== 23, "size wrong(%i)\n",sz
);
1729 ok( 0 == strcmp(buffer
,"{a[one]bc[two]de[one]f}"), "wrong output (%s)\n",buffer
);
1732 r
= MsiRecordSetStringA(hrec
, 0, "{a[one]bc[bad]de[two]f}");
1733 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1734 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1735 ok( r
== ERROR_SUCCESS
, "format failed\n");
1736 ok( sz
== 23, "size wrong(%i)\n",sz
);
1737 ok( 0 == strcmp(buffer
,"{a[one]bc[bad]de[two]f}"), "wrong output (%s)\n",buffer
);
1740 r
= MsiRecordSetStringA(hrec
, 0, "{[bad]}");
1741 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1742 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1743 ok( r
== ERROR_SUCCESS
, "format failed\n");
1744 ok( sz
== 7, "size wrong(%i)\n",sz
);
1745 ok( 0 == strcmp(buffer
,"{[bad]}"), "wrong output (%s)\n",buffer
);
1748 r
= MsiRecordSetStringA(hrec
, 0, "{abc{d[one]ef}"); /* missing final brace */
1749 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1750 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1751 ok( r
== ERROR_SUCCESS
, "format failed\n");
1752 ok( sz
== 14, "size wrong(%i)\n",sz
);
1753 ok( 0 == strcmp(buffer
,"{abc{d[one]ef}"), "wrong output (%s)\n",buffer
);
1756 r
= MsiRecordSetStringA(hrec
, 0, "{abc{d[one]ef}}");
1757 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1758 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1759 ok( r
== ERROR_SUCCESS
, "format failed\n");
1760 ok( sz
== 15, "size wrong(%i)\n",sz
);
1761 ok( 0 == strcmp(buffer
,"{abc{d[one]ef}}"), "wrong output (%s)\n",buffer
);
1764 r
= MsiRecordSetStringA(hrec
, 0, "{abc}{{def}hi{j[one]k}}");
1765 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1766 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1767 ok( r
== ERROR_SUCCESS
, "format failed\n");
1768 ok( sz
== 5, "size wrong(%i)\n",sz
);
1769 ok( 0 == strcmp(buffer
,"{abc}"), "wrong output (%s)\n",buffer
);
1772 r
= MsiRecordSetStringA(hrec
, 0, "{{def}hi{j[one]k}}");
1773 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1774 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1775 ok( r
== ERROR_SUCCESS
, "format failed\n");
1776 ok( sz
== 0, "size wrong(%i)\n",sz
);
1777 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
1780 r
= MsiRecordSetStringA(hrec
, 0, "{{def}hi{jk}}");
1781 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1782 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1783 ok( r
== ERROR_SUCCESS
, "format failed\n");
1784 ok( sz
== 0, "size wrong(%i)\n",sz
);
1785 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
1788 r
= MsiRecordSetStringA(hrec
, 0, "{{{def}}hi{jk}}");
1789 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1790 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1791 ok( r
== ERROR_SUCCESS
, "format failed\n");
1794 ok( sz
== 7, "size wrong(%i)\n",sz
);
1795 ok( 0 == strcmp(buffer
,"hi{jk}}"), "wrong output (%s)\n",buffer
);
1799 r
= MsiRecordSetStringA(hrec
, 0, "{{def}hi{{jk}}}");
1800 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1801 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1802 ok( r
== ERROR_SUCCESS
, "format failed\n");
1805 ok( sz
== 1, "size wrong(%i)\n",sz
);
1806 ok( 0 == strcmp(buffer
,"}"), "wrong output (%s)\n",buffer
);
1810 r
= MsiRecordSetStringA(hrec
, 0, "{{def}{jk}}");
1811 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1812 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1813 ok( r
== ERROR_SUCCESS
, "format failed\n");
1814 ok( sz
== 0, "size wrong(%i)\n",sz
);
1815 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
1818 r
= MsiRecordSetStringA(hrec
, 0, "{{def}}");
1819 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1820 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1821 ok( r
== ERROR_SUCCESS
, "format failed\n");
1822 ok( sz
== 0, "size wrong(%i)\n",sz
);
1823 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
1826 r
= MsiRecordSetStringA(hrec
, 0, "{a{b}c}");
1827 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1828 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1829 ok( r
== ERROR_SUCCESS
, "format failed\n");
1830 ok( sz
== 7, "size wrong(%i)\n",sz
);
1831 ok( 0 == strcmp(buffer
,"{a{b}c}"), "wrong output (%s)\n",buffer
);
1834 r
= MsiRecordSetStringA(hrec
, 0, "{a{b}}");
1835 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1836 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1837 ok( r
== ERROR_SUCCESS
, "format failed\n");
1838 ok( sz
== 6, "size wrong(%i)\n",sz
);
1839 ok( 0 == strcmp(buffer
,"{a{b}}"), "wrong output (%s)\n",buffer
);
1842 r
= MsiRecordSetStringA(hrec
, 0, "{{b}c}");
1843 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1844 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1845 ok( r
== ERROR_SUCCESS
, "format failed\n");
1846 ok( sz
== 6, "size wrong(%i)\n",sz
);
1847 ok( 0 == strcmp(buffer
,"{{b}c}"), "wrong output (%s)\n",buffer
);
1850 r
= MsiRecordSetStringA(hrec
, 0, "{{{{}}}}");
1851 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1852 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1853 ok( r
== ERROR_SUCCESS
, "format failed\n");
1856 ok( sz
== 2, "size wrong(%i)\n",sz
);
1857 ok( 0 == strcmp(buffer
,"}}"), "wrong output (%s)\n",buffer
);
1861 MsiRecordSetInteger(hrec
, 1, 100);
1862 MsiRecordSetInteger(hrec
, 2, -100);
1863 r
= MsiRecordSetStringA(hrec
, 0, "[1] [2]");
1864 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1865 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1866 ok( r
== ERROR_SUCCESS
, "format failed\n");
1867 ok( sz
== 8, "size wrong(%i)\n",sz
);
1868 ok( 0 == strcmp(buffer
,"100 -100"), "wrong output (%s)\n",buffer
);
1870 sz
= sizeof(buffer
);
1871 r
= MsiRecordSetStringA(hrec
, 0, "[1] {[noprop] [twoprop]} {abcdef}");
1872 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1873 r
= MsiRecordSetStringA(hrec
, 1, "one");
1874 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1875 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1876 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1877 ok(sz
== 33, "Expected 33, got %d\n",sz
);
1878 ok(!lstrcmpA(buffer
, "one {[noprop] [twoprop]} {abcdef}"),
1879 "Expected \"one {[noprop] [twoprop]} {abcdef}\", got \"%s\"\n", buffer
);
1881 sz
= sizeof(buffer
);
1882 r
= MsiRecordSetStringA(hrec
, 0, "[1] {[noprop] [one]} {abcdef}");
1883 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1884 r
= MsiRecordSetStringA(hrec
, 1, "one");
1885 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1886 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1887 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1888 ok(sz
== 29, "Expected 29, got %d\n",sz
);
1889 ok(!lstrcmpA(buffer
, "one {[noprop] [one]} {abcdef}"),
1890 "Expected \"one {[noprop] [one]} {abcdef}\", got \"%s\"\n", buffer
);
1892 sz
= sizeof(buffer
);
1893 r
= MsiRecordSetStringA(hrec
, 0, "[1] {[one]} {abcdef}");
1894 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1895 r
= MsiRecordSetStringA(hrec
, 1, "one");
1896 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1897 r
= MsiFormatRecordA(0, hrec
, buffer
, &sz
);
1898 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1899 ok(sz
== 20, "Expected 20, got %d\n",sz
);
1900 ok(!lstrcmpA(buffer
, "one {[one]} {abcdef}"),
1901 "Expected \"one {[one]} {abcdef}\", got \"%s\"\n", buffer
);
1903 MsiCloseHandle( hrec
);
1906 static void test_formatrecord_package(void)
1914 r
= helper_createpackage( msifile
, &package
);
1915 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1917 skip("Not enough rights to perform tests\n");
1920 ok( r
== ERROR_SUCCESS
, "Unable to create package %u\n", r
);
1922 hrec
= MsiCreateRecord(12);
1923 ok( hrec
, "failed to create record\n");
1925 r
= MsiFormatRecordA(package
, 0, NULL
, NULL
);
1926 ok( r
== ERROR_INVALID_HANDLE
, "wrong error\n");
1928 r
= MsiFormatRecordA(package
, hrec
, NULL
, NULL
);
1929 ok( r
== ERROR_SUCCESS
, "format failed\n");
1931 r
= MsiRecordSetStringA(hrec
,0,NULL
);
1932 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1933 r
= MsiRecordSetStringA(hrec
,1,NULL
);
1934 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1935 r
= MsiRecordSetStringA(hrec
,2,NULL
);
1936 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1937 r
= MsiRecordSetStringA(hrec
,3,NULL
);
1938 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1939 r
= MsiRecordSetStringA(hrec
,4,NULL
);
1940 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1941 r
= MsiRecordSetStringA(hrec
,5,NULL
);
1942 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1943 r
= MsiRecordSetStringA(hrec
,6,NULL
);
1944 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1945 r
= MsiRecordSetStringA(hrec
,7,NULL
);
1946 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1947 r
= MsiRecordSetStringA(hrec
,8,NULL
);
1948 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1949 r
= MsiRecordSetStringA(hrec
,9,NULL
);
1950 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1951 r
= MsiRecordSetStringA(hrec
,10,NULL
);
1952 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1953 r
= MsiRecordSetStringA(hrec
,11,NULL
);
1954 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1955 r
= MsiRecordSetStringA(hrec
,12,NULL
);
1956 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1959 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
1960 ok( r
== ERROR_SUCCESS
, "format failed with empty buffer (%i)\n",r
);
1961 ok( sz
== 51, "size wrong (%i)\n",sz
);
1962 ok( 0 == strcmp(buffer
,"1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: "), "wrong output(%s)\n",buffer
);
1964 r
= MsiSetPropertyA(package
, "prop", "val");
1965 ok( r
== ERROR_SUCCESS
, "failed to set propertY: %d\n", r
);
1967 r
= MsiRecordSetStringA(hrec
, 0, NULL
);
1968 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1969 r
= MsiRecordSetStringA(hrec
, 1, "[2]");
1970 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1971 r
= MsiRecordSetStringA(hrec
, 2, "stuff");
1972 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1973 r
= MsiRecordSetStringA(hrec
, 3, "prop");
1974 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1975 r
= MsiRecordSetStringA(hrec
, 4, "[prop]");
1976 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1977 r
= MsiRecordSetStringA(hrec
, 5, "[noprop]");
1978 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1980 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
1981 ok( r
== ERROR_SUCCESS
, "format failed with empty buffer (%i)\n",r
);
1984 ok( sz
== 66, "size wrong (%i)\n",sz
);
1985 ok( !lstrcmpA(buffer
,
1986 "1: [2] 2: stuff 3: prop 4: val 5: 6: 7: 8: 9: 10: 11: 12: "),
1987 "wrong output(%s)\n",buffer
);
1990 /* now put play games with escaping */
1991 r
= MsiRecordSetStringA(hrec
, 0, "[1] [2] [\\3asdf]");
1992 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1993 r
= MsiRecordSetStringA(hrec
, 1, "boo");
1994 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1995 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
1996 ok( r
== ERROR_SUCCESS
, "set string failed\n");
1998 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
1999 ok( r
== ERROR_SUCCESS
, "format failed\n");
2000 ok( sz
== 9, "size wrong(%i)\n",sz
);
2001 ok( 0 == strcmp(buffer
,"boo hoo 3"), "wrong output (%s)\n",buffer
);
2003 r
= MsiRecordSetStringA(hrec
, 0, "[1] [2] [\\x]");
2004 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2005 r
= MsiRecordSetStringA(hrec
, 1, "boo");
2006 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2007 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
2008 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2010 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2011 ok( r
== ERROR_SUCCESS
, "format failed\n");
2012 ok( sz
== 9, "size wrong(%i)\n",sz
);
2013 ok( 0 == strcmp(buffer
,"boo hoo x"), "wrong output (%s)\n",buffer
);
2015 MsiRecordSetStringA(hrec
, 0, "[\\x]");
2017 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2018 ok( r
== ERROR_SUCCESS
, "format failed\n");
2019 ok( sz
== 1, "size wrong: %d\n", sz
);
2020 ok( 0 == strcmp(buffer
,"x"), "wrong output: %s\n", buffer
);
2022 MsiRecordSetStringA(hrec
, 0, "{\\x}");
2024 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2025 ok( r
== ERROR_SUCCESS
, "format failed\n");
2026 ok( sz
== 4, "size wrong: %d\n", sz
);
2027 ok( 0 == strcmp(buffer
,"{\\x}"), "wrong output: %s\n", buffer
);
2029 MsiRecordSetStringA(hrec
, 0, "[abc\\x]");
2031 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2032 ok( r
== ERROR_SUCCESS
, "format failed\n");
2033 ok( sz
== 0, "size wrong: %d\n", sz
);
2034 ok( 0 == strcmp(buffer
,""), "wrong output: %s\n", buffer
);
2036 MsiRecordSetStringA(hrec
, 0, "[abc\\xdef]");
2038 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2039 ok( r
== ERROR_SUCCESS
, "format failed\n");
2040 ok( sz
== 0, "size wrong: %d\n", sz
);
2041 ok( 0 == strcmp(buffer
,""), "wrong output: %s\n", buffer
);
2043 MsiRecordSetStringA(hrec
, 0, "\\x");
2044 sz
= sizeof(buffer
);
2045 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2046 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2047 ok(sz
== 2, "Expected 2, got %d\n", sz
);
2048 ok(!lstrcmpA(buffer
, "\\x"), "Expected \"\\x\", got \"%s\"\n", buffer
);
2050 MsiRecordSetStringA(hrec
, 0, "[\\[");
2051 sz
= sizeof(buffer
);
2052 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2053 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2054 ok(sz
== 3, "Expected 3, got %d\n", sz
);
2055 ok(!lstrcmpA(buffer
, "[\\["), "Expected \"[\\[\", got \"%s\"\n", buffer
);
2057 MsiRecordSetStringA(hrec
, 0, "[\\[]");
2058 sz
= sizeof(buffer
);
2059 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2060 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2061 ok(sz
== 1, "Expected 1, got %d\n", sz
);
2062 ok(!lstrcmpA(buffer
, "["), "Expected \"[\", got \"%s\"\n", buffer
);
2064 MsiRecordSetStringA(hrec
, 0, "[[]");
2065 sz
= sizeof(buffer
);
2066 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2067 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2068 ok(sz
== 3, "Expected 3, got %d\n", sz
);
2069 ok(!lstrcmpA(buffer
, "[[]"), "Expected \"[]\", got \"%s\"\n", buffer
);
2071 MsiRecordSetStringA(hrec
, 0, "[\\[]]");
2072 sz
= sizeof(buffer
);
2073 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2074 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2075 ok(sz
== 2, "Expected 2, got %d\n", sz
);
2076 ok(!lstrcmpA(buffer
, "[]"), "Expected \"[]\", got \"%s\"\n", buffer
);
2078 MsiRecordSetStringA(hrec
, 0, "[\\[a]");
2079 sz
= sizeof(buffer
);
2080 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2081 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2082 ok(sz
== 1, "Expected 1, got %d\n", sz
);
2083 ok(!lstrcmpA(buffer
, "["), "Expected \"[\", got \"%s\"\n", buffer
);
2085 MsiRecordSetStringA(hrec
, 0, "[\\a[]");
2086 sz
= sizeof(buffer
);
2087 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2088 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2091 ok(sz
== 1, "Expected 1, got %d\n", sz
);
2092 ok(!lstrcmpA(buffer
, "a"), "Expected \"a\", got \"%s\"\n", buffer
);
2095 MsiRecordSetStringA(hrec
, 0, "[prop]");
2096 sz
= sizeof(buffer
);
2097 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2098 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2099 ok(sz
== 3, "Expected 3, got %d\n", sz
);
2100 ok(!lstrcmpA(buffer
, "val"), "Expected \"val\", got \"%s\"\n", buffer
);
2102 MsiRecordSetStringA(hrec
, 0, "[prop] [pro\\pblah] [prop]");
2103 sz
= sizeof(buffer
);
2104 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2105 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2106 ok(sz
== 8, "Expected 8, got %d\n", sz
);
2107 ok(!lstrcmpA(buffer
, "val val"), "Expected \"val val\", got \"%s\"\n", buffer
);
2109 MsiSetPropertyA(package
, "b", "ball");
2110 MsiRecordSetStringA(hrec
, 0, "[\\b]");
2111 sz
= sizeof(buffer
);
2112 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2113 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2114 ok(sz
== 1, "Expected 1, got %d\n", sz
);
2115 ok(!lstrcmpA(buffer
, "b"), "Expected \"b\", got \"%s\"\n", buffer
);
2117 MsiRecordSetStringA(hrec
, 0, "[\\c]");
2118 sz
= sizeof(buffer
);
2119 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2120 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2121 ok(sz
== 1, "Expected 1, got %d\n", sz
);
2122 ok(!lstrcmpA(buffer
, "c"), "Expected \"c\", got \"%s\"\n", buffer
);
2124 MsiRecordSetStringA(hrec
, 0, "[\\[]prop]");
2125 sz
= sizeof(buffer
);
2126 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2127 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2128 ok(sz
== 6, "Expected 6, got %d\n", sz
);
2129 ok(!lstrcmpA(buffer
, "[prop]"), "Expected \"[prop]\", got \"%s\"\n", buffer
);
2131 MsiRecordSetStringA(hrec
, 0, "[\\a]prop]");
2132 sz
= sizeof(buffer
);
2133 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2134 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2135 ok(sz
== 6, "Expected 6, got %d\n", sz
);
2136 ok(!lstrcmpA(buffer
, "aprop]"), "Expected \"aprop]\", got \"%s\"\n", buffer
);
2138 MsiRecordSetStringA(hrec
, 0, "[\\[]Bracket Text[\\]]");
2140 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2141 ok( r
== ERROR_SUCCESS
, "format failed\n");
2142 ok( sz
== 14, "size wrong: %d\n", sz
);
2143 ok( 0 == strcmp(buffer
,"[Bracket Text]"), "wrong output: %s\n", buffer
);
2145 /* null characters */
2146 r
= MsiRecordSetStringA(hrec
, 0, "[1] [~] [2]");
2147 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2148 r
= MsiRecordSetStringA(hrec
, 1, "boo");
2149 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2150 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
2151 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2153 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2154 ok( r
== ERROR_SUCCESS
, "format failed\n");
2155 ok( sz
== 9, "size wrong: %d\n", sz
);
2156 ok( 0 == strcmp(buffer
,"boo "), "wrong output: %s\n", buffer
);
2157 ok(!lstrcmpA(&buffer
[5], " hoo"),
2158 "Expected \" hoo\", got \"%s\"\n", &buffer
[5]);
2160 r
= MsiRecordSetStringA(hrec
, 0, "[1] [~abc] [2]");
2161 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2162 r
= MsiRecordSetStringA(hrec
, 1, "boo");
2163 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2164 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
2165 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2166 sz
= sizeof(buffer
);
2167 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2168 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2169 ok(sz
== 8, "Expected 8, got %d\n", sz
);
2170 ok(!lstrcmpA(buffer
, "boo hoo"), "Expected \"boo hoo\", got \"%s\"\n", buffer
);
2173 r
= MsiSetPropertyA(package
,"dummy","Bork");
2174 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2175 r
= MsiRecordSetStringA(hrec
, 0, "[1] [dummy] [2]");
2176 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2177 r
= MsiRecordSetStringA(hrec
, 1, "boo");
2178 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2179 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
2180 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2182 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2183 ok( r
== ERROR_SUCCESS
, "format failed\n");
2184 ok( sz
== 12, "size wrong\n");
2185 ok( 0 == strcmp(buffer
,"boo Bork hoo"), "wrong output\n");
2187 r
= MsiRecordSetStringA(hrec
, 0, "[1] [invalid] [2]");
2188 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2189 r
= MsiRecordSetStringA(hrec
, 1, "boo");
2190 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2191 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
2192 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2194 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2195 ok( r
== ERROR_SUCCESS
, "format failed\n");
2196 ok( sz
== 8, "size wrong\n");
2197 ok( 0 == strcmp(buffer
,"boo hoo"), "wrong output\n");
2200 r
= MsiSetPropertyA(package
,"dummya","foo");
2201 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2202 r
= MsiSetPropertyA(package
,"dummyb","baa");
2203 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2204 r
= MsiSetPropertyA(package
,"adummyc","whoa");
2205 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2206 r
= MsiRecordSetStringA(hrec
, 0, "[dummy[1]] [dummy[2]] [[1]dummy[3]]");
2207 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2208 r
= MsiRecordSetStringA(hrec
, 1, "a");
2209 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2210 r
= MsiRecordSetStringA(hrec
, 2, "b");
2211 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2212 r
= MsiRecordSetStringA(hrec
, 3, "c");
2213 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2215 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2216 ok( r
== ERROR_SUCCESS
, "format failed\n");
2217 ok( sz
== 12, "size wrong(%i)\n",sz
);
2218 ok( 0 == strcmp(buffer
,"foo baa whoa"), "wrong output (%s)\n",buffer
);
2220 r
= MsiSetPropertyA(package
,"dummya","1");
2221 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2222 r
= MsiSetPropertyA(package
,"dummyb","[2]");
2223 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2224 r
= MsiRecordSetStringA(hrec
, 0, "[dummya] [[dummya]] [dummyb]");
2225 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2226 r
= MsiRecordSetStringA(hrec
, 1, "aaa");
2227 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2228 r
= MsiRecordSetStringA(hrec
, 2, "bbb");
2229 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2230 r
= MsiRecordSetStringA(hrec
, 3, "ccc");
2231 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2233 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2234 ok( r
== ERROR_SUCCESS
, "format failed\n");
2237 ok( sz
== 9, "size wrong(%i)\n",sz
);
2238 ok( 0 == strcmp(buffer
,"1 [1] [2]"), "wrong output (%s)\n",buffer
);
2241 r
= MsiSetPropertyA(package
,"dummya","1");
2242 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2243 r
= MsiSetPropertyA(package
,"dummyb","a");
2244 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2245 r
= MsiSetPropertyA(package
,"dummyc","\\blath");
2246 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2247 r
= MsiSetPropertyA(package
,"dummyd","[\\blath]");
2248 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2249 r
= MsiRecordSetStringA(hrec
, 0, "[dummyc] [[dummyc]] [dummy[dummyb]]");
2250 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2251 r
= MsiRecordSetStringA(hrec
, 1, "aaa");
2252 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2253 r
= MsiRecordSetStringA(hrec
, 2, "bbb");
2254 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2255 r
= MsiRecordSetStringA(hrec
, 3, "ccc");
2256 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2258 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2259 ok( r
== ERROR_SUCCESS
, "format failed\n");
2260 ok( sz
== 10, "size wrong(%i)\n",sz
);
2261 ok( 0 == strcmp(buffer
,"\\blath b 1"), "wrong output (%s)\n",buffer
);
2263 r
= MsiRecordSetStringA(hrec
, 0, "[1] [2] [[\\3asdf]]");
2264 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2265 r
= MsiRecordSetStringA(hrec
, 1, "boo");
2266 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2267 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
2268 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2269 r
= MsiRecordSetStringA(hrec
, 3, "yeah");
2270 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2272 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2273 ok( r
== ERROR_SUCCESS
, "format failed\n");
2276 ok( sz
== 11, "size wrong(%i)\n",sz
);
2277 ok( 0 == strcmp(buffer
,"boo hoo [3]"), "wrong output (%s)\n",buffer
);
2280 r
= MsiRecordSetStringA(hrec
, 0, "[1] [2] [[3]]");
2281 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2282 r
= MsiRecordSetStringA(hrec
, 1, "boo");
2283 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2284 r
= MsiRecordSetStringA(hrec
, 2, "hoo");
2285 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2286 r
= MsiRecordSetStringA(hrec
, 3, "\\help");
2287 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2289 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2290 ok( r
== ERROR_SUCCESS
, "format failed\n");
2291 ok( sz
== 9, "size wrong(%i)\n",sz
);
2292 ok( 0 == strcmp(buffer
,"boo hoo h"), "wrong output (%s)\n",buffer
);
2294 /* nested properties */
2295 MsiSetPropertyA(package
, "PropA", "surprise");
2296 MsiSetPropertyA(package
, "PropB", "[PropA]");
2297 MsiSetPropertyA(package
, "PropC", "[PropB]");
2299 MsiRecordSetStringA(hrec
, 0, "[PropC]");
2300 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2301 ok( r
== ERROR_SUCCESS
, "format failed\n");
2302 ok( sz
== 7, "size wrong(%i)\n",sz
);
2303 ok( 0 == strcmp(buffer
,"[PropB]"), "wrong output (%s)\n",buffer
);
2305 MsiSetPropertyA(package
, "PropA", "surprise");
2306 MsiSetPropertyA(package
, "PropB", "PropA");
2307 MsiSetPropertyA(package
, "PropC", "PropB");
2309 MsiRecordSetStringA(hrec
, 0, "[PropC]");
2310 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2311 ok( r
== ERROR_SUCCESS
, "format failed\n");
2312 ok( sz
== 5, "size wrong(%i)\n",sz
);
2313 ok( 0 == strcmp(buffer
,"PropB"), "wrong output (%s)\n",buffer
);
2315 MsiSetPropertyA(package
, "PropA", "surprise");
2316 MsiSetPropertyA(package
, "PropB", "[PropA]");
2317 MsiSetPropertyA(package
, "PropC", "[PropB]");
2319 MsiRecordSetStringA(hrec
, 0, "[[PropC]]");
2320 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2321 ok( r
== ERROR_SUCCESS
, "format failed\n");
2322 ok( sz
== 0, "size wrong(%i)\n",sz
);
2323 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
2325 MsiSetPropertyA(package
, "PropA", "surprise");
2326 MsiSetPropertyA(package
, "PropB", "[PropA]");
2327 MsiSetPropertyA(package
, "PropC", "PropB");
2329 MsiRecordSetStringA(hrec
, 0, "[[PropC]]");
2330 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2331 ok( r
== ERROR_SUCCESS
, "format failed\n");
2332 ok( sz
== 7, "size wrong(%i)\n",sz
);
2333 ok( 0 == strcmp(buffer
,"[PropA]"), "wrong output (%s)\n",buffer
);
2335 MsiSetPropertyA(package
, "PropA", "surprise");
2336 MsiSetPropertyA(package
, "PropB", "PropA");
2337 MsiSetPropertyA(package
, "PropC", "PropB");
2339 MsiRecordSetStringA(hrec
, 0, "[[PropC]]");
2340 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2341 ok( r
== ERROR_SUCCESS
, "format failed\n");
2342 ok( sz
== 5, "size wrong(%i)\n",sz
);
2343 ok( 0 == strcmp(buffer
,"PropA"), "wrong output (%s)\n",buffer
);
2345 MsiSetPropertyA(package
, "PropA", "surprise");
2346 MsiSetPropertyA(package
, "PropB", "PropA");
2347 MsiSetPropertyA(package
, "PropC", "PropB");
2349 MsiRecordSetStringA(hrec
, 0, "[[[PropC]]]");
2350 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2351 ok( r
== ERROR_SUCCESS
, "format failed\n");
2352 ok( sz
== 8, "size wrong(%i)\n",sz
);
2353 ok( 0 == strcmp(buffer
,"surprise"), "wrong output (%s)\n",buffer
);
2355 /* properties inside braces */
2357 MsiRecordSetStringA(hrec
, 0, "{abcd}");
2358 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2359 ok( r
== ERROR_SUCCESS
, "format failed\n");
2360 ok( sz
== 6, "size wrong(%i)\n",sz
);
2361 ok( 0 == strcmp(buffer
,"{abcd}"), "wrong output (%s)\n",buffer
);
2363 MsiSetPropertyA(package
, "one", "mercury");
2364 MsiSetPropertyA(package
, "two", "venus");
2366 MsiRecordSetStringA(hrec
, 0, "{a[one]bc[two]de[one]f}");
2367 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2368 ok( r
== ERROR_SUCCESS
, "format failed: %d\n", r
);
2369 ok( sz
== 25, "size wrong(%i)\n",sz
);
2370 ok( 0 == strcmp(buffer
,"amercurybcvenusdemercuryf"), "wrong output (%s)\n",buffer
);
2372 MsiSetPropertyA(package
, "one", "mercury");
2373 MsiSetPropertyA(package
, "two", "venus");
2374 MsiSetPropertyA(package
, "bad", "");
2376 MsiRecordSetStringA(hrec
, 0, "{a[one]bc[bad]de[two]f}");
2377 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2378 ok( r
== ERROR_SUCCESS
, "format failed\n");
2379 ok( sz
== 0, "size wrong(%i)\n",sz
);
2380 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
2382 MsiSetPropertyA(package
, "bad", "");
2384 MsiRecordSetStringA(hrec
, 0, "{[bad]}");
2385 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2386 ok( r
== ERROR_SUCCESS
, "format failed\n");
2387 ok( sz
== 0, "size wrong(%i)\n",sz
);
2388 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
2390 MsiSetPropertyA(package
, "one", "mercury");
2392 MsiRecordSetStringA(hrec
, 0, "{abc{d[one]ef}"); /* missing final brace */
2393 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2394 ok( r
== ERROR_SUCCESS
, "format failed\n");
2397 ok( sz
== 14, "size wrong(%i)\n",sz
);
2398 ok( 0 == strcmp(buffer
,"abc{dmercuryef"), "wrong output (%s)\n",buffer
);
2401 MsiSetPropertyA(package
, "one", "mercury");
2403 MsiRecordSetStringA(hrec
, 0, "{abc{d[one]ef}}");
2404 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2405 ok( r
== ERROR_SUCCESS
, "format failed\n");
2408 ok( sz
== 15, "size wrong(%i)\n",sz
);
2409 ok( 0 == strcmp(buffer
,"abc{dmercuryef}"), "wrong output (%s)\n",buffer
);
2412 MsiSetPropertyA(package
, "one", "mercury");
2414 MsiRecordSetStringA(hrec
, 0, "{abc}{{def}hi{j[one]k}}");
2415 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2416 ok( r
== ERROR_SUCCESS
, "format failed\n");
2417 ok( sz
== 5, "size wrong(%i)\n",sz
);
2418 ok( 0 == strcmp(buffer
,"{abc}"), "wrong output (%s)\n",buffer
);
2420 MsiSetPropertyA(package
, "one", "mercury");
2423 MsiRecordSetStringA(hrec
, 0, "{{def}hi{j[one]k}}");
2424 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2425 ok( r
== ERROR_SUCCESS
, "format failed\n");
2426 ok( sz
== 0, "size wrong(%i)\n",sz
);
2427 ok( 0 == strcmp(buffer
,""), "wrong output (%s)\n",buffer
);
2429 sz
= sizeof(buffer
);
2430 MsiRecordSetStringA(hrec
, 0, "[1] {[noprop] [twoprop]} {abcdef}");
2431 MsiRecordSetStringA(hrec
, 1, "one");
2432 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2433 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2434 ok(sz
== 13, "Expected 13, got %d\n",sz
);
2435 ok(!lstrcmpA(buffer
, "one {abcdef}"),
2436 "Expected \"one {abcdef}\", got \"%s\"\n", buffer
);
2438 sz
= sizeof(buffer
);
2439 MsiRecordSetStringA(hrec
, 0, "[1] {[noprop] [one]} {abcdef}");
2440 MsiRecordSetStringA(hrec
, 1, "one");
2441 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2442 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2443 ok(sz
== 13, "Expected 13, got %d\n",sz
);
2444 ok(!lstrcmpA(buffer
, "one {abcdef}"),
2445 "Expected \"one {abcdef}\", got \"%s\"\n", buffer
);
2447 sz
= sizeof(buffer
);
2448 MsiRecordSetStringA(hrec
, 0, "[1] {[one]} {abcdef}");
2449 MsiRecordSetStringA(hrec
, 1, "one");
2450 r
= MsiFormatRecordA(package
, hrec
, buffer
, &sz
);
2451 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2452 ok(sz
== 20, "Expected 20, got %d\n",sz
);
2453 ok(!lstrcmpA(buffer
, "one mercury {abcdef}"),
2454 "Expected \"one mercury {abcdef}\", got \"%s\"\n", buffer
);
2456 MsiCloseHandle(hrec
);
2458 r
= MsiCloseHandle(package
);
2459 ok(r
==ERROR_SUCCESS
, "Unable to close package\n");
2461 DeleteFileA( msifile
);
2464 static void test_formatrecord_tables(void)
2466 MSIHANDLE hdb
, hrec
, hpkg
= 0;
2468 CHAR curr_dir
[MAX_PATH
];
2469 CHAR expected
[MAX_PATH
];
2470 CHAR root
[MAX_PATH
];
2474 GetCurrentDirectoryA( MAX_PATH
, curr_dir
);
2476 hdb
= create_package_db();
2477 ok ( hdb
, "failed to create package database\n");
2479 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
2480 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
2482 r
= add_directory_entry( hdb
, "'ReallyLongDir', 'TARGETDIR', "
2483 "'I am a really long directory'" );
2484 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
2486 r
= create_feature_table( hdb
);
2487 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
2489 r
= add_feature_entry( hdb
, "'occipitofrontalis', '', '', '', 2, 1, '', 0" );
2490 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2492 r
= create_component_table( hdb
);
2493 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
2495 r
= add_component_entry( hdb
, "'frontal', '', 'TARGETDIR', 0, '', 'frontal_file'" );
2496 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2498 r
= add_component_entry( hdb
, "'parietal', '', 'TARGETDIR', 1, '', 'parietal_file'" );
2499 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2501 r
= add_component_entry( hdb
, "'temporal', '', 'ReallyLongDir', 0, '', 'temporal_file'" );
2502 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2504 r
= create_feature_components_table( hdb
);
2505 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
2507 r
= add_feature_components_entry( hdb
, "'occipitofrontalis', 'frontal'" );
2508 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2510 r
= add_feature_components_entry( hdb
, "'occipitofrontalis', 'parietal'" );
2511 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2513 r
= add_feature_components_entry( hdb
, "'occipitofrontalis', 'temporal'" );
2514 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2516 r
= create_file_table( hdb
);
2517 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
2519 r
= add_file_entry( hdb
, "'frontal_file', 'frontal', 'frontal.txt', 0, '', '1033', 8192, 1" );
2520 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2522 r
= add_file_entry( hdb
, "'parietal_file', 'parietal', 'parietal.txt', 0, '', '1033', 8192, 1" );
2523 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2525 r
= add_file_entry( hdb
, "'temporal_file', 'temporal', 'temporal.txt', 0, '', '1033', 8192, 1" );
2526 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2528 r
= create_custom_action_table( hdb
);
2529 ok( r
== ERROR_SUCCESS
, "cannot create CustomAction table: %d\n", r
);
2531 r
= add_custom_action_entry( hdb
, "'MyCustom', 51, 'prop', '[!temporal_file]'" );
2532 ok( r
== ERROR_SUCCESS
, "cannot add custom action: %d\n", r
);
2534 r
= add_custom_action_entry( hdb
, "'EscapeIt1', 51, 'prop', '[\\[]Bracket Text[\\]]'" );
2535 ok( r
== ERROR_SUCCESS
, "cannot add custom action: %d\n", r
);
2537 r
= add_custom_action_entry( hdb
, "'EscapeIt2', 51, 'prop', '[\\xabcd]'" );
2538 ok( r
== ERROR_SUCCESS
, "cannot add custom action: %d\n", r
);
2540 r
= add_custom_action_entry( hdb
, "'EscapeIt3', 51, 'prop', '[abcd\\xefgh]'" );
2541 ok( r
== ERROR_SUCCESS
, "cannot add custom action: %d\n", r
);
2543 r
= add_custom_action_entry( hdb
, "'EmbedNull', 51, 'prop', '[~]np'" );
2544 ok( r
== ERROR_SUCCESS
, "cannot add custom action: %d\n", r
);
2546 r
= package_from_db( hdb
, &hpkg
);
2547 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2549 skip("Not enough rights to perform tests\n");
2550 MsiCloseHandle( hdb
);
2551 DeleteFileA( msifile
);
2554 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2556 MsiCloseHandle( hdb
);
2558 r
= MsiSetPropertyA( hpkg
, "imaprop", "ringer" );
2559 ok( r
== ERROR_SUCCESS
, "cannot set property: %d\n", r
);
2561 hrec
= MsiCreateRecord( 1 );
2563 /* property doesn't exist */
2565 /*MsiRecordSetStringA( hrec, 0, "[1]" ); */
2566 MsiRecordSetStringA( hrec
, 1, "[idontexist]" );
2567 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2568 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2569 ok( !lstrcmpA( buf
, "1: " ), "Expected '1: ', got %s\n", buf
);
2571 /* property exists */
2573 MsiRecordSetStringA( hrec
, 1, "[imaprop]" );
2574 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2575 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2576 ok( !lstrcmpA( buf
, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf
);
2578 /* environment variable doesn't exist */
2580 MsiRecordSetStringA( hrec
, 1, "[%idontexist]" );
2581 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2582 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2583 ok( !lstrcmpA( buf
, "1: " ), "Expected '1: ', got %s\n", buf
);
2585 /* environment variable exists */
2587 SetEnvironmentVariableA( "crazyvar", "crazyval" );
2588 MsiRecordSetStringA( hrec
, 1, "[%crazyvar]" );
2589 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2590 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2591 ok( !lstrcmpA( buf
, "1: crazyval " ), "Expected '1: crazyval ', got %s\n", buf
);
2593 /* file key before CostInitialize */
2595 MsiRecordSetStringA( hrec
, 1, "[#frontal_file]" );
2596 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2597 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2598 ok( !lstrcmpA( buf
, "1: " ), "Expected '1: ', got %s\n", buf
);
2600 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
2602 r
= MsiDoActionA(hpkg
, "CostInitialize");
2603 ok( r
== ERROR_SUCCESS
, "CostInitialize failed: %d\n", r
);
2605 r
= MsiDoActionA(hpkg
, "FileCost");
2606 ok( r
== ERROR_SUCCESS
, "FileCost failed: %d\n", r
);
2608 r
= MsiDoActionA(hpkg
, "CostFinalize");
2609 ok( r
== ERROR_SUCCESS
, "CostFinalize failed: %d\n", r
);
2612 MsiGetPropertyA( hpkg
, "ROOTDRIVE", root
, &size
);
2614 sprintf( expected
, "1: %sfrontal.txt ", root
);
2616 /* frontal full file key */
2618 MsiRecordSetStringA( hrec
, 1, "[#frontal_file]" );
2619 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2620 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2621 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2623 /* frontal short file key */
2625 MsiRecordSetStringA( hrec
, 1, "[!frontal_file]" );
2626 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2627 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2628 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2630 sprintf( expected
, "1: %sI am a really long directory\\temporal.txt ", root
);
2632 /* temporal full file key */
2634 MsiRecordSetStringA( hrec
, 1, "[#temporal_file]" );
2635 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2636 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2637 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2639 /* temporal short file key */
2641 MsiRecordSetStringA( hrec
, 1, "[!temporal_file]" );
2642 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2643 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2644 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2646 /* custom action 51, files don't exist */
2647 r
= MsiDoActionA( hpkg
, "MyCustom" );
2648 ok( r
== ERROR_SUCCESS
, "MyCustom failed: %d\n", r
);
2650 sprintf( expected
, "%sI am a really long directory\\temporal.txt", root
);
2653 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2654 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2655 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2657 sprintf( buf
, "%sI am a really long directory", root
);
2658 CreateDirectoryA( buf
, NULL
);
2660 lstrcatA( buf
, "\\temporal.txt" );
2661 create_test_file( buf
);
2663 /* custom action 51, files exist */
2664 r
= MsiDoActionA( hpkg
, "MyCustom" );
2665 ok( r
== ERROR_SUCCESS
, "MyCustom failed: %d\n", r
);
2668 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2669 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2672 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2675 /* custom action 51, escaped text 1 */
2676 r
= MsiDoActionA( hpkg
, "EscapeIt1" );
2677 ok( r
== ERROR_SUCCESS
, "EscapeIt1 failed: %d\n", r
);
2680 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2681 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2682 ok( !lstrcmpA( buf
, "[Bracket Text]" ), "Expected '[Bracket Text]', got %s\n", buf
);
2684 /* custom action 51, escaped text 2 */
2685 r
= MsiDoActionA( hpkg
, "EscapeIt2" );
2686 ok( r
== ERROR_SUCCESS
, "EscapeIt2 failed: %d\n", r
);
2689 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2690 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2691 ok( !lstrcmpA( buf
, "x" ), "Expected 'x', got %s\n", buf
);
2693 /* custom action 51, escaped text 3 */
2694 r
= MsiDoActionA( hpkg
, "EscapeIt3" );
2695 ok( r
== ERROR_SUCCESS
, "EscapeIt3 failed: %d\n", r
);
2698 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2699 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2700 ok( !lstrcmpA( buf
, "" ), "Expected '', got %s\n", buf
);
2702 /* custom action 51, embedded null */
2703 r
= MsiDoActionA( hpkg
, "EmbedNull" );
2704 ok( r
== ERROR_SUCCESS
, "EmbedNull failed: %d\n", r
);
2707 memset( buf
, 'a', sizeof(buf
) );
2708 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2709 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2710 ok( !memcmp( buf
, "\0np", sizeof("\0np") ), "wrong value\n");
2711 ok( size
== sizeof("\0np") - 1, "got %u\n", size
);
2713 r
= MsiSetPropertyA( hpkg
, "prop", "[~]np" );
2714 ok( r
== ERROR_SUCCESS
, "cannot set property: %d\n", r
);
2717 memset( buf
, 'a', sizeof(buf
) );
2718 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2719 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2720 ok( !lstrcmpA( buf
, "[~]np" ), "Expected '[~]np', got %s\n", buf
);
2722 sprintf( expected
, "1: %sI am a really long directory\\ ", root
);
2724 /* component with INSTALLSTATE_LOCAL */
2726 MsiRecordSetStringA( hrec
, 1, "[$temporal]" );
2727 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2728 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2729 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2731 r
= MsiSetComponentStateA( hpkg
, "temporal", INSTALLSTATE_SOURCE
);
2732 ok( r
== ERROR_SUCCESS
, "failed to set install state: %d\n", r
);
2734 /* component with INSTALLSTATE_SOURCE */
2735 lstrcpyA( expected
, "1: " );
2736 lstrcatA( expected
, curr_dir
);
2737 if (strlen(curr_dir
) > 3) lstrcatA( expected
, "\\" );
2738 lstrcatA( expected
, " " );
2740 MsiRecordSetStringA( hrec
, 1, "[$parietal]" );
2741 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2742 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2743 ok( !lstrcmpA( buf
, expected
), "Expected '%s', got '%s'\n", expected
, buf
);
2745 sprintf( buf
, "%sI am a really long directory\\temporal.txt", root
);
2748 sprintf( buf
, "%sI am a really long directory", root
);
2749 RemoveDirectoryA( buf
);
2751 MsiCloseHandle( hrec
);
2752 MsiCloseHandle( hpkg
);
2753 DeleteFileA( msifile
);
2756 static void test_processmessage(void)
2758 MSIHANDLE hrec
, package
;
2761 MsiSetInternalUI(INSTALLUILEVEL_BASIC
, NULL
);
2763 r
= helper_createpackage( msifile
, &package
);
2764 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2766 skip("Not enough rights to perform tests\n");
2769 ok( r
== ERROR_SUCCESS
, "Unable to create package %u\n", r
);
2771 hrec
= MsiCreateRecord(3);
2772 ok( hrec
, "failed to create record\n");
2774 r
= MsiRecordSetStringA(hrec
, 1, "");
2775 ok( r
== ERROR_SUCCESS
, "set string failed\n");
2777 r
= MsiProcessMessage(package
, INSTALLMESSAGE_ACTIONSTART
, hrec
);
2778 ok( r
== IDOK
, "expected IDOK, got %i\n", r
);
2780 MsiCloseHandle(hrec
);
2781 MsiCloseHandle(package
);
2783 DeleteFileA(msifile
);
2788 test_createpackage();
2789 test_formatrecord();
2790 test_formatrecord_package();
2791 test_formatrecord_tables();
2792 test_processmessage();