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