2 * Unit tests for profile functions
4 * Copyright (c) 2003 Stefan Leichter
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
29 #define KEY "ProfileInt"
30 #define SECTION "Test"
31 #define TESTFILE ".\\testwine.ini"
32 #define TESTFILE2 ".\\testwine2.ini"
44 static void test_profile_int(void)
46 struct _profileInt profileInt[]={
47 { NULL, NULL, NULL, NULL, 70, 0 , 0}, /* 0 */
48 { NULL, NULL, NULL, TESTFILE, -1, 4294967295U, 0},
49 { NULL, NULL, NULL, TESTFILE, 1, 1 , 0},
50 { SECTION, NULL, NULL, TESTFILE, -1, 4294967295U, 0},
51 { SECTION, NULL, NULL, TESTFILE, 1, 1 , 0},
52 { NULL, KEY, NULL, TESTFILE, -1, 4294967295U, 0}, /* 5 */
53 { NULL, KEY, NULL, TESTFILE, 1, 1 , 0},
54 { SECTION, KEY, NULL, TESTFILE, -1, 4294967295U, 4294967295U},
55 { SECTION, KEY, NULL, TESTFILE, 1, 1 , 1},
56 { SECTION, KEY, "-1", TESTFILE, -1, 4294967295U, 4294967295U},
57 { SECTION, KEY, "-1", TESTFILE, 1, 4294967295U, 4294967295U}, /* 10 */
58 { SECTION, KEY, "1", TESTFILE, -1, 1 , 1},
59 { SECTION, KEY, "1", TESTFILE, 1, 1 , 1},
60 { SECTION, KEY, "+1", TESTFILE, -1, 1 , 0},
61 { SECTION, KEY, "+1", TESTFILE, 1, 1 , 0},
62 { SECTION, KEY, "4294967296", TESTFILE, -1, 0 , 0}, /* 15 */
63 { SECTION, KEY, "4294967296", TESTFILE, 1, 0 , 0},
64 { SECTION, KEY, "4294967297", TESTFILE, -1, 1 , 1},
65 { SECTION, KEY, "4294967297", TESTFILE, 1, 1 , 1},
66 { SECTION, KEY, "-4294967297", TESTFILE, -1, 4294967295U, 4294967295U},
67 { SECTION, KEY, "-4294967297", TESTFILE, 1, 4294967295U, 4294967295U}, /* 20 */
68 { SECTION, KEY, "42A94967297", TESTFILE, -1, 42 , 42},
69 { SECTION, KEY, "42A94967297", TESTFILE, 1, 42 , 42},
70 { SECTION, KEY, "B4294967297", TESTFILE, -1, 0 , 0},
71 { SECTION, KEY, "B4294967297", TESTFILE, 1, 0 , 0},
73 int i, num_test = (sizeof(profileInt)/sizeof(struct _profileInt));
76 DeleteFileA( TESTFILE);
78 for (i=0; i < num_test; i++) {
79 if (profileInt[i].value)
80 WritePrivateProfileStringA(SECTION, KEY, profileInt[i].value,
81 profileInt[i].iniFile);
83 res = GetPrivateProfileIntA(profileInt[i].section, profileInt[i].key,
84 profileInt[i].defaultVal, profileInt[i].iniFile);
85 ok((res == profileInt[i].result) || (res == profileInt[i].result9x),
86 "test<%02d>: ret<%010u> exp<%010u><%010u>\n",
87 i, res, profileInt[i].result, profileInt[i].result9x);
90 DeleteFileA( TESTFILE);
93 static void test_profile_string(void)
95 static WCHAR emptyW[] = { 0 };
96 static WCHAR keyW[] = { 'k','e','y',0 };
97 static WCHAR sW[] = { 's',0 };
98 static WCHAR TESTFILE2W[] = {'.','\\','t','e','s','t','w','i','n','e','2','.','i','n','i',0};
99 static WCHAR valsectionW[] = {'v','a','l','_','e','_','s','e','c','t','i','o','n',0 };
100 static WCHAR valnokeyW[] = {'v','a','l','_','n','o','_','k','e','y',0};
107 /* test that lines without an '=' will not be enumerated */
108 /* in the case below, name2 is a key while name3 is not. */
109 char content[]="[s]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n";
110 char content2[]="\r\nkey=val_no_section\r\n[]\r\nkey=val_e_section\r\n"
111 "[s]\r\n=val_no_key\r\n[t]\r\n";
112 DeleteFileA( TESTFILE2);
113 h = CreateFileA( TESTFILE2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
114 FILE_ATTRIBUTE_NORMAL, NULL);
115 ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", TESTFILE2);
116 if( h == INVALID_HANDLE_VALUE) return;
117 WriteFile( h, content, sizeof(content), &count, NULL);
120 /* enumerate the keys */
121 ret=GetPrivateProfileStringA( "s", NULL, "", buf, sizeof(buf),
123 for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
126 ok( ret == 18 && !strcmp( buf, "name1,name2,name4"), "wrong keys returned(%d): %s\n", ret,
129 /* add a new key to test that the file is quite usable */
130 WritePrivateProfileStringA( "s", "name5", "val5", TESTFILE2);
131 ret=GetPrivateProfileStringA( "s", NULL, "", buf, sizeof(buf),
133 for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
135 ok( ret == 24 && !strcmp( buf, "name1,name2,name4,name5"), "wrong keys returned(%d): %s\n",
138 h = CreateFileA( TESTFILE2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
139 FILE_ATTRIBUTE_NORMAL, NULL);
140 ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", TESTFILE2);
141 if( h == INVALID_HANDLE_VALUE) return;
142 WriteFile( h, content2, sizeof(content2), &count, NULL);
145 /* works only in unicode, ascii crashes */
146 ret=GetPrivateProfileStringW(emptyW, keyW, emptyW, bufW,
147 sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
149 ok(!lstrcmpW(valsectionW,bufW), "expected %s, got %s\n",
150 wine_dbgstr_w(valsectionW), wine_dbgstr_w(bufW) );
152 /* works only in unicode, ascii crashes */
153 ret=GetPrivateProfileStringW(sW, emptyW, emptyW, bufW,
154 sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
156 ok(!lstrcmpW(valnokeyW,bufW), "expected %s, got %s\n",
157 wine_dbgstr_w(valnokeyW), wine_dbgstr_w(bufW) );
159 DeleteFileA( TESTFILE2);
162 static void test_profile_sections(void)
169 static const char content[]="[section1]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n[section2]\r\n";
170 static const char testfile4[]=".\\testwine4.ini";
171 BOOL on_win98 = FALSE;
173 DeleteFileA( testfile4 );
174 h = CreateFileA( testfile4, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
175 ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", testfile4);
176 if( h == INVALID_HANDLE_VALUE) return;
177 WriteFile( h, content, sizeof(content), &count, NULL);
180 /* Some parameter checking */
181 SetLastError(0xdeadbeef);
182 ret = GetPrivateProfileSectionA( NULL, NULL, 0, NULL );
183 ok( ret == 0, "expected return size 0, got %d\n", ret );
184 ok( GetLastError() == ERROR_INVALID_PARAMETER ||
185 GetLastError() == 0xdeadbeef /* Win98 */,
186 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
187 if (GetLastError() == 0xdeadbeef) on_win98 = TRUE;
189 SetLastError(0xdeadbeef);
190 ret = GetPrivateProfileSectionA( NULL, NULL, 0, testfile4 );
191 ok( ret == 0, "expected return size 0, got %d\n", ret );
192 ok( GetLastError() == ERROR_INVALID_PARAMETER ||
193 GetLastError() == 0xdeadbeef /* Win98 */,
194 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
198 SetLastError(0xdeadbeef);
199 ret = GetPrivateProfileSectionA( "section1", NULL, 0, testfile4 );
200 ok( ret == 0, "expected return size 0, got %d\n", ret );
201 ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
204 SetLastError(0xdeadbeef);
205 ret = GetPrivateProfileSectionA( NULL, buf, sizeof(buf), testfile4 );
206 ok( ret == 0, "expected return size 0, got %d\n", ret );
207 ok( GetLastError() == ERROR_INVALID_PARAMETER ||
208 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
209 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
211 SetLastError(0xdeadbeef);
212 ret = GetPrivateProfileSectionA( "section1", buf, sizeof(buf), NULL );
213 ok( ret == 0, "expected return size 0, got %d\n", ret );
215 ok( GetLastError() == ERROR_FILE_NOT_FOUND ||
216 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
217 "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
219 /* Existing empty section with no keys */
220 SetLastError(0xdeadbeef);
221 ret=GetPrivateProfileSectionA("section2", buf, sizeof(buf), testfile4);
222 ok( ret == 0, "expected return size 0, got %d\n", ret );
223 ok( GetLastError() == ERROR_SUCCESS ||
224 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
225 "expected ERROR_SUCCESS, got %d\n", GetLastError());
227 /* Existing section with keys and values*/
228 SetLastError(0xdeadbeef);
229 ret=GetPrivateProfileSectionA("section1", buf, sizeof(buf), testfile4);
230 for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
232 ok( ret == 35 && !strcmp( buf, "name1=val1,name2=,name3,name4=val4"), "wrong section returned(%d): %s\n",
234 ok( buf[ret-1] == 0 && buf[ret] == 0, "returned buffer not terminated with double-null\n" );
235 ok( GetLastError() == ERROR_SUCCESS ||
236 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
237 "expected ERROR_SUCCESS, got %d\n", GetLastError());
240 ret=GetPrivateProfileSectionA("section1", buf, 24, testfile4);
241 for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
243 ok( ret == 22 && !strcmp( buf, "name1=val1,name2=,name"), "wrong section returned(%d): %s\n",
245 ok( buf[ret] == 0 && buf[ret+1] == 0, "returned buffer not terminated with double-null\n" );
247 DeleteFileA( testfile4 );
250 static void test_profile_sections_names(void)
257 static const char content[]="[section1]\r\n[section2]\r\n[section3]\r\n";
258 static const char testfile3[]=".\\testwine3.ini";
259 static const WCHAR testfile3W[]={ '.','\\','t','e','s','t','w','i','n','e','3','.','i','n','i',0 };
260 static const WCHAR not_here[] = {'.','\\','n','o','t','_','h','e','r','e','.','i','n','i',0};
261 DeleteFileA( testfile3 );
262 h = CreateFileA( testfile3, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
263 FILE_ATTRIBUTE_NORMAL, NULL);
264 ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", testfile3);
265 if( h == INVALID_HANDLE_VALUE) return;
266 WriteFile( h, content, sizeof(content), &count, NULL);
269 /* Test with sufficiently large buffer */
270 memset(buf, 0xc, sizeof(buf));
271 ret = GetPrivateProfileSectionNamesA( buf, 29, testfile3 );
273 broken(ret == 28), /* Win9x, WinME */
274 "expected return size 27, got %d\n", ret );
275 ok( (buf[ret-1] == 0 && buf[ret] == 0) ||
276 broken(buf[ret-1] == 0 && buf[ret-2] == 0), /* Win9x, WinME */
277 "returned buffer not terminated with double-null\n" );
279 /* Test with exactly fitting buffer */
280 memset(buf, 0xc, sizeof(buf));
281 ret = GetPrivateProfileSectionNamesA( buf, 28, testfile3 );
283 broken(ret == 28), /* Win9x, WinME */
284 "expected return size 26, got %d\n", ret );
286 ok( (buf[ret+1] == 0 && buf[ret] == 0) || /* W2K3 and higher */
287 broken(buf[ret+1] == 0xc && buf[ret] == 0) || /* NT4, W2K, WinXP */
288 broken(buf[ret-1] == 0 && buf[ret-2] == 0), /* Win9x, WinME */
289 "returned buffer not terminated with double-null\n" );
291 /* Test with a buffer too small */
292 memset(buf, 0xc, sizeof(buf));
293 ret = GetPrivateProfileSectionNamesA( buf, 27, testfile3 );
294 ok( ret == 25, "expected return size 25, got %d\n", ret );
295 /* Win9x and WinME only fills the buffer with complete section names (double-null terminated) */
296 count = strlen("section1") + sizeof(CHAR) + strlen("section2");
298 ok( (buf[ret+1] == 0 && buf[ret] == 0) ||
299 broken(buf[count] == 0 && buf[count+1] == 0), /* Win9x, WinME */
300 "returned buffer not terminated with double-null\n" );
302 /* Tests on nonexistent file */
303 memset(buf, 0xc, sizeof(buf));
304 ret = GetPrivateProfileSectionNamesA( buf, 10, ".\\not_here.ini" );
306 broken(ret == 1), /* Win9x, WinME */
307 "expected return size 0, got %d\n", ret );
308 ok( buf[0] == 0, "returned buffer not terminated with null\n" );
309 ok( buf[1] != 0, "returned buffer terminated with double-null\n" );
311 /* Test with sufficiently large buffer */
312 SetLastError(0xdeadbeef);
313 memset(bufW, 0xcc, sizeof(bufW));
314 ret = GetPrivateProfileSectionNamesW( bufW, 29, testfile3W );
315 if (ret == 0 && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
317 win_skip("GetPrivateProfileSectionNamesW is not implemented\n");
318 DeleteFileA( testfile3 );
321 ok( ret == 27, "expected return size 27, got %d\n", ret );
322 ok( bufW[ret-1] == 0 && bufW[ret] == 0, "returned buffer not terminated with double-null\n" );
324 /* Test with exactly fitting buffer */
325 memset(bufW, 0xcc, sizeof(bufW));
326 ret = GetPrivateProfileSectionNamesW( bufW, 28, testfile3W );
327 ok( ret == 26, "expected return size 26, got %d\n", ret );
328 ok( (bufW[ret+1] == 0 && bufW[ret] == 0) || /* W2K3 and higher */
329 broken(bufW[ret+1] == 0xcccc && bufW[ret] == 0), /* NT4, W2K, WinXP */
330 "returned buffer not terminated with double-null\n" );
332 /* Test with a buffer too small */
333 memset(bufW, 0xcc, sizeof(bufW));
334 ret = GetPrivateProfileSectionNamesW( bufW, 27, testfile3W );
335 ok( ret == 25, "expected return size 25, got %d\n", ret );
336 ok( bufW[ret+1] == 0 && bufW[ret] == 0, "returned buffer not terminated with double-null\n" );
338 DeleteFileA( testfile3 );
340 /* Tests on nonexistent file */
341 memset(bufW, 0xcc, sizeof(bufW));
342 ret = GetPrivateProfileSectionNamesW( bufW, 10, not_here );
343 ok( ret == 0, "expected return size 0, got %d\n", ret );
344 ok( bufW[0] == 0, "returned buffer not terminated with null\n" );
345 ok( bufW[1] != 0, "returned buffer terminated with double-null\n" );
348 /* If the ini-file has already been opened with CreateFile, WritePrivateProfileString failed in wine with an error ERROR_SHARING_VIOLATION, some testing here */
349 static void test_profile_existing(void)
351 static const char *testfile1 = ".\\winesharing1.ini";
352 static const char *testfile2 = ".\\winesharing2.ini";
354 static const struct {
355 DWORD dwDesiredAccess;
361 {GENERIC_READ, FILE_SHARE_READ, ERROR_SHARING_VIOLATION, FALSE },
362 {GENERIC_READ, FILE_SHARE_WRITE, ERROR_SHARING_VIOLATION, TRUE },
363 {GENERIC_WRITE, FILE_SHARE_READ, ERROR_SHARING_VIOLATION, FALSE },
364 {GENERIC_WRITE, FILE_SHARE_WRITE, ERROR_SHARING_VIOLATION, TRUE },
365 {GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, ERROR_SHARING_VIOLATION, FALSE },
366 {GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE, ERROR_SHARING_VIOLATION, TRUE },
367 {GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, FALSE, ERROR_SHARING_VIOLATION /* nt4 */},
368 {GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, FALSE, ERROR_SHARING_VIOLATION /* nt4 */},
369 /*Thief demo (bug 5024) opens .ini file like this*/
370 {GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, FALSE, ERROR_SHARING_VIOLATION /* nt4 */}
377 char buffer[MAX_PATH];
379 for (i=0; i < sizeof(pe)/sizeof(pe[0]); i++)
381 h = CreateFile(testfile1, pe[i].dwDesiredAccess, pe[i].dwShareMode, NULL,
382 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
383 ok(INVALID_HANDLE_VALUE != h, "%d: CreateFile failed\n",i);
384 SetLastError(0xdeadbeef);
386 ret = WritePrivateProfileString(SECTION, KEY, "12345", testfile1);
387 if (!pe[i].write_error)
390 ok( broken(GetLastError() == pe[i].broken_error),
391 "%d: WritePrivateProfileString failed with error %u\n", i, GetLastError() );
393 size = GetPrivateProfileString(SECTION, KEY, 0, buffer, MAX_PATH, testfile1);
395 ok( size == 5, "%d: test failed, number of characters copied: %d instead of 5\n", i, size );
397 ok( !size, "%d: test failed, number of characters copied: %d instead of 0\n", i, size );
401 DWORD err = GetLastError();
402 ok( !ret, "%d: WritePrivateProfileString succeeded\n", i );
404 ok( err == pe[i].write_error, "%d: WritePrivateProfileString failed with error %u/%u\n",
405 i, err, pe[i].write_error );
407 size = GetPrivateProfileString(SECTION, KEY, 0, buffer, MAX_PATH, testfile1);
408 ok( !size, "%d: test failed, number of characters copied: %d instead of 0\n", i, size );
411 ok( DeleteFile(testfile1), "delete failed\n" );
414 h = CreateFile(testfile2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
415 sprintf( buffer, "[%s]\r\n%s=123\r\n", SECTION, KEY );
416 ok( WriteFile( h, buffer, strlen(buffer), &size, NULL ), "failed to write\n" );
419 for (i=0; i < sizeof(pe)/sizeof(pe[0]); i++)
421 h = CreateFile(testfile2, pe[i].dwDesiredAccess, pe[i].dwShareMode, NULL,
422 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
423 ok(INVALID_HANDLE_VALUE != h, "%d: CreateFile failed\n",i);
424 SetLastError(0xdeadbeef);
425 ret = GetPrivateProfileStringA(SECTION, KEY, NULL, buffer, MAX_PATH, testfile2);
426 /* Win9x and WinME returns 0 for all cases except the first one */
427 if (!pe[i].read_error)
429 broken(!ret && GetLastError() == 0xdeadbeef), /* Win9x, WinME */
430 "%d: GetPrivateProfileString failed with error %u\n", i, GetLastError() );
432 ok( !ret, "%d: GetPrivateProfileString succeeded\n", i );
435 ok( DeleteFile(testfile2), "delete failed\n" );
438 static void test_profile_delete_on_close(void)
440 static CHAR testfile[] = ".\\testwine5.ini";
443 static const char contents[] = "[" SECTION "]\n" KEY "=123\n";
445 h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
446 CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
447 ok( WriteFile( h, contents, sizeof contents - 1, &size, NULL ),
448 "Cannot write test file: %x\n", GetLastError() );
449 ok( size == sizeof contents - 1, "Test file: partial write\n");
451 SetLastError(0xdeadbeef);
452 res = GetPrivateProfileInt(SECTION, KEY, 0, testfile);
454 broken(res == 0 && GetLastError() == ERROR_SHARING_VIOLATION), /* Win9x, WinME */
455 "Got %d instead of 123\n", res);
457 /* This also deletes the file */
461 static void test_profile_refresh(void)
463 static CHAR testfile[] = ".\\winetest4.ini";
466 static const char contents1[] = "[" SECTION "]\n" KEY "=123\n";
467 static const char contents2[] = "[" SECTION "]\n" KEY "=124\n";
469 h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
470 CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
471 ok( WriteFile( h, contents1, sizeof contents1 - 1, &size, NULL ),
472 "Cannot write test file: %x\n", GetLastError() );
473 ok( size == sizeof contents1 - 1, "Test file: partial write\n");
475 SetLastError(0xdeadbeef);
476 res = GetPrivateProfileInt(SECTION, KEY, 0, testfile);
478 broken(res == 0 && GetLastError() == ERROR_SHARING_VIOLATION), /* Win9x, WinME */
479 "Got %d instead of 123\n", res);
483 /* Test proper invalidation of wine's profile file cache */
485 h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
486 CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
487 ok( WriteFile( h, contents2, sizeof contents2 - 1, &size, NULL ),
488 "Cannot write test file: %x\n", GetLastError() );
489 ok( size == sizeof contents2 - 1, "Test file: partial write\n");
491 SetLastError(0xdeadbeef);
492 res = GetPrivateProfileInt(SECTION, KEY, 0, testfile);
494 broken(res == 0 && GetLastError() == 0xdeadbeef), /* Win9x, WinME */
495 "Got %d instead of 124\n", res);
497 /* This also deletes the file */
501 static void create_test_file(LPCSTR name, LPCSTR data, DWORD size)
506 hfile = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
507 ok(hfile != INVALID_HANDLE_VALUE, "cannot create %s\n", name);
508 WriteFile(hfile, data, size, &count, NULL);
512 static BOOL emptystr_ok(CHAR emptystr[MAX_PATH])
516 for(i = 0;i < MAX_PATH;++i)
519 trace("emptystr[%d] = %d\n",i,emptystr[i]);
526 static void test_GetPrivateProfileString(const char *content, const char *descript)
530 CHAR def_val[MAX_PATH];
532 CHAR windir[MAX_PATH];
533 /* NT series crashes on r/o empty strings, so pass an r/w
534 empty string and check for modification */
535 CHAR emptystr[MAX_PATH] = "";
538 static const char filename[] = ".\\winetest.ini";
540 trace("test_GetPrivateProfileStringA: %s\n", descript);
542 if(!lstrcmpA(descript, "CR only"))
544 SetLastError(0xdeadbeef);
545 ret = GetPrivateProfileStringW(NULL, NULL, NULL,
547 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
549 win_skip("Win9x and WinME don't handle 'CR only' correctly\n");
554 create_test_file(filename, content, lstrlenA(content));
556 /* Run this test series with caching. Wine won't cache profile
557 files younger than 2.1 seconds. */
560 /* lpAppName is NULL */
561 memset(buf, 0xc, sizeof(buf));
562 lstrcpyA(buf, "kumquat");
563 ret = GetPrivateProfileStringA(NULL, "name1", "default",
564 buf, MAX_PATH, filename);
566 broken(ret == 19), /* Win9x and WinME */
567 "Expected 18, got %d\n", ret);
568 len = lstrlenA("section1") + sizeof(CHAR) + lstrlenA("section2") + 2 * sizeof(CHAR);
569 ok(!memcmp(buf, "section1\0section2\0\0", len),
570 "Expected \"section1\\0section2\\0\\0\", got \"%s\"\n", buf);
572 /* lpAppName is empty */
573 memset(buf, 0xc, sizeof(buf));
574 lstrcpyA(buf, "kumquat");
575 ret = GetPrivateProfileStringA(emptystr, "name1", "default",
576 buf, MAX_PATH, filename);
577 ok(ret == 7, "Expected 7, got %d\n", ret);
578 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
579 ok(emptystr_ok(emptystr), "AppName modified\n");
581 /* lpAppName is missing */
582 memset(buf, 0xc,sizeof(buf));
583 lstrcpyA(buf, "kumquat");
584 ret = GetPrivateProfileStringA("notasection", "name1", "default",
585 buf, MAX_PATH, filename);
586 ok(ret == 7, "Expected 7, got %d\n", ret);
587 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
589 /* lpAppName is empty, lpDefault is NULL */
590 memset(buf, 0xc,sizeof(buf));
591 lstrcpyA(buf, "kumquat");
592 ret = GetPrivateProfileStringA(emptystr, "name1", NULL,
593 buf, MAX_PATH, filename);
594 ok(ret == 0, "Expected 0, got %d\n", ret);
595 ok(!lstrcmpA(buf, "") ||
596 broken(!lstrcmpA(buf, "kumquat")), /* Win9x, WinME */
597 "Expected \"\", got \"%s\"\n", buf);
598 ok(emptystr_ok(emptystr), "AppName modified\n");
600 /* lpAppName is empty, lpDefault is empty */
601 memset(buf, 0xc,sizeof(buf));
602 lstrcpyA(buf, "kumquat");
603 ret = GetPrivateProfileStringA(emptystr, "name1", "",
604 buf, MAX_PATH, filename);
605 ok(ret == 0, "Expected 0, got %d\n", ret);
606 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
607 ok(emptystr_ok(emptystr), "AppName modified\n");
609 /* lpAppName is empty, lpDefault has trailing blank characters */
610 memset(buf, 0xc,sizeof(buf));
611 lstrcpyA(buf, "kumquat");
612 /* lpDefault must be writable (trailing blanks are removed inplace in win9x) */
613 lstrcpyA(def_val, "default ");
614 ret = GetPrivateProfileStringA(emptystr, "name1", def_val,
615 buf, MAX_PATH, filename);
616 ok(ret == 7, "Expected 7, got %d\n", ret);
617 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
618 ok(emptystr_ok(emptystr), "AppName modified\n");
620 /* lpAppName is empty, many blank characters in lpDefault */
621 memset(buf, 0xc,sizeof(buf));
622 lstrcpyA(buf, "kumquat");
623 /* lpDefault must be writable (trailing blanks are removed inplace in win9x) */
624 lstrcpyA(def_val, "one two ");
625 ret = GetPrivateProfileStringA(emptystr, "name1", def_val,
626 buf, MAX_PATH, filename);
627 ok(ret == 7, "Expected 7, got %d\n", ret);
628 ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
629 ok(emptystr_ok(emptystr), "AppName modified\n");
631 /* lpAppName is empty, blank character but not trailing in lpDefault */
632 memset(buf, 0xc,sizeof(buf));
633 lstrcpyA(buf, "kumquat");
634 ret = GetPrivateProfileStringA(emptystr, "name1", "one two",
635 buf, MAX_PATH, filename);
636 ok(ret == 7, "Expected 7, got %d\n", ret);
637 ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
638 ok(emptystr_ok(emptystr), "AppName modified\n");
640 /* lpKeyName is NULL */
641 memset(buf, 0xc,sizeof(buf));
642 lstrcpyA(buf, "kumquat");
643 ret = GetPrivateProfileStringA("section1", NULL, "default",
644 buf, MAX_PATH, filename);
645 ok(ret == 18, "Expected 18, got %d\n", ret);
646 ok(!memcmp(buf, "name1\0name2\0name4\0", ret + 1),
647 "Expected \"name1\\0name2\\0name4\\0\", got \"%s\"\n", buf);
649 /* lpKeyName is empty */
650 memset(buf, 0xc,sizeof(buf));
651 lstrcpyA(buf, "kumquat");
652 ret = GetPrivateProfileStringA("section1", emptystr, "default",
653 buf, MAX_PATH, filename);
654 ok(ret == 7, "Expected 7, got %d\n", ret);
655 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
656 ok(emptystr_ok(emptystr), "KeyName modified\n");
658 /* lpKeyName is missing */
659 memset(buf, 0xc,sizeof(buf));
660 lstrcpyA(buf, "kumquat");
661 ret = GetPrivateProfileStringA("section1", "notakey", "default",
662 buf, MAX_PATH, filename);
663 ok(ret == 7, "Expected 7, got %d\n", ret);
664 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
666 /* lpKeyName is empty, lpDefault is NULL */
667 memset(buf, 0xc,sizeof(buf));
668 lstrcpyA(buf, "kumquat");
669 ret = GetPrivateProfileStringA("section1", emptystr, NULL,
670 buf, MAX_PATH, filename);
671 ok(ret == 0, "Expected 0, got %d\n", ret);
672 ok(!lstrcmpA(buf, "") ||
673 broken(!lstrcmpA(buf, "kumquat")), /* Win9x, WinME */
674 "Expected \"\", got \"%s\"\n", buf);
675 ok(emptystr_ok(emptystr), "KeyName modified\n");
677 /* lpKeyName is empty, lpDefault is empty */
678 memset(buf, 0xc,sizeof(buf));
679 lstrcpyA(buf, "kumquat");
680 ret = GetPrivateProfileStringA("section1", emptystr, "",
681 buf, MAX_PATH, filename);
682 ok(ret == 0, "Expected 0, got %d\n", ret);
683 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
684 ok(emptystr_ok(emptystr), "KeyName modified\n");
686 /* lpKeyName is empty, lpDefault has trailing blank characters */
687 memset(buf, 0xc,sizeof(buf));
688 lstrcpyA(buf, "kumquat");
689 /* lpDefault must be writable (trailing blanks are removed inplace in win9x) */
690 lstrcpyA(def_val, "default ");
691 ret = GetPrivateProfileStringA("section1", emptystr, def_val,
692 buf, MAX_PATH, filename);
693 ok(ret == 7, "Expected 7, got %d\n", ret);
694 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
695 ok(emptystr_ok(emptystr), "KeyName modified\n");
699 /* lpReturnedString is NULL */
700 ret = GetPrivateProfileStringA("section1", "name1", "default",
701 NULL, MAX_PATH, filename);
704 /* lpFileName is NULL */
705 memset(buf, 0xc,sizeof(buf));
706 lstrcpyA(buf, "kumquat");
707 ret = GetPrivateProfileStringA("section1", "name1", "default",
708 buf, MAX_PATH, NULL);
710 broken(ret == 0), /* Win9x, WinME */
711 "Expected 7, got %d\n", ret);
712 ok(!lstrcmpA(buf, "default") ||
713 broken(!lstrcmpA(buf, "kumquat")), /* Win9x, WinME */
714 "Expected \"default\", got \"%s\"\n", buf);
716 /* lpFileName is empty */
717 memset(buf, 0xc,sizeof(buf));
718 lstrcpyA(buf, "kumquat");
719 ret = GetPrivateProfileStringA("section1", "name1", "default",
721 ok(ret == 7, "Expected 7, got %d\n", ret);
722 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
724 /* lpFileName is nonexistent */
725 memset(buf, 0xc,sizeof(buf));
726 lstrcpyA(buf, "kumquat");
727 ret = GetPrivateProfileStringA("section1", "name1", "default",
728 buf, MAX_PATH, "nonexistent");
729 ok(ret == 7, "Expected 7, got %d\n", ret);
730 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
733 memset(buf, 0xc,sizeof(buf));
734 lstrcpyA(buf, "kumquat");
735 ret = GetPrivateProfileStringA("section1", "name1", "default",
737 ok(ret == 0, "Expected 0, got %d\n", ret);
738 ok(!lstrcmpA(buf, "kumquat"), "Expected buf to be unchanged, got \"%s\"\n", buf);
740 /* nSize is exact size of output */
741 memset(buf, 0xc,sizeof(buf));
742 lstrcpyA(buf, "kumquat");
743 ret = GetPrivateProfileStringA("section1", "name1", "default",
745 ok(ret == 3, "Expected 3, got %d\n", ret);
746 ok(!lstrcmpA(buf, "val"), "Expected \"val\", got \"%s\"\n", buf);
748 /* nSize has room for NULL terminator */
749 memset(buf, 0xc,sizeof(buf));
750 lstrcpyA(buf, "kumquat");
751 ret = GetPrivateProfileStringA("section1", "name1", "default",
753 ok(ret == 4, "Expected 4, got %d\n", ret);
754 ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
756 /* output is 1 character */
757 memset(buf, 0xc,sizeof(buf));
758 lstrcpyA(buf, "kumquat");
759 ret = GetPrivateProfileStringA("section1", "name4", "default",
760 buf, MAX_PATH, filename);
761 ok(ret == 1, "Expected 1, got %d\n", ret);
762 ok(!lstrcmpA(buf, "a"), "Expected \"a\", got \"%s\"\n", buf);
764 /* output is 1 character, no room for NULL terminator */
765 memset(buf, 0xc,sizeof(buf));
766 lstrcpyA(buf, "kumquat");
767 ret = GetPrivateProfileStringA("section1", "name4", "default",
769 ok(ret == 0, "Expected 0, got %d\n", ret);
770 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
772 /* lpAppName is NULL, not enough room for final section name */
773 memset(buf, 0xc,sizeof(buf));
774 lstrcpyA(buf, "kumquat");
775 ret = GetPrivateProfileStringA(NULL, "name1", "default",
777 ok(ret == 14, "Expected 14, got %d\n", ret);
778 len = lstrlenA("section1") + 2 * sizeof(CHAR);
780 ok(!memcmp(buf, "section1\0secti\0\0", ret + 2) ||
781 broken(!memcmp(buf, "section1\0\0", len)), /* Win9x, WinME */
782 "Expected \"section1\\0secti\\0\\0\", got \"%s\"\n", buf);
784 /* lpKeyName is NULL, not enough room for final key name */
785 memset(buf, 0xc,sizeof(buf));
786 lstrcpyA(buf, "kumquat");
787 ret = GetPrivateProfileStringA("section1", NULL, "default",
789 ok(ret == 14, "Expected 14, got %d\n", ret);
791 ok(!memcmp(buf, "name1\0name2\0na\0\0", ret + 2) ||
792 broken(!memcmp(buf, "name1\0name2\0n\0\0", ret + 1)), /* Win9x, WinME */
793 "Expected \"name1\\0name2\\0na\\0\\0\", got \"%s\"\n", buf);
795 /* key value has quotation marks which are stripped */
796 memset(buf, 0xc,sizeof(buf));
797 lstrcpyA(buf, "kumquat");
798 ret = GetPrivateProfileStringA("section1", "name2", "default",
799 buf, MAX_PATH, filename);
800 ok(ret == 4, "Expected 4, got %d\n", ret);
801 ok(!lstrcmpA(buf, "val2"), "Expected \"val2\", got \"%s\"\n", buf);
803 /* case does not match */
804 memset(buf, 0xc,sizeof(buf));
805 lstrcpyA(buf, "kumquat");
806 ret = GetPrivateProfileStringA("section1", "NaMe1", "default",
807 buf, MAX_PATH, filename);
808 ok(ret == 4, "Expected 4, got %d\n", ret);
809 ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
811 /* only filename is used */
812 memset(buf, 0xc,sizeof(buf));
813 lstrcpyA(buf, "kumquat");
814 ret = GetPrivateProfileStringA("section1", "NaMe1", "default",
815 buf, MAX_PATH, "winetest.ini");
816 ok(ret == 7, "Expected 7, got %d\n", ret);
817 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
819 GetWindowsDirectoryA(windir, MAX_PATH);
820 SetLastError(0xdeadbeef);
821 ret = GetTempFileNameA(windir, "pre", 0, path);
822 if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
824 skip("Not allowed to create a file in the Windows directory\n");
825 DeleteFileA(filename);
828 tempfile = strrchr(path, '\\') + 1;
829 create_test_file(path, content, lstrlenA(content));
831 /* only filename is used, file exists in windows directory */
832 memset(buf, 0xc,sizeof(buf));
833 lstrcpyA(buf, "kumquat");
834 ret = GetPrivateProfileStringA("section1", "NaMe1", "default",
835 buf, MAX_PATH, tempfile);
836 ok(ret == 4, "Expected 4, got %d\n", ret);
837 ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
839 /* successful case */
840 memset(buf, 0xc,sizeof(buf));
841 lstrcpyA(buf, "kumquat");
842 ret = GetPrivateProfileStringA("section1", "name1", "default",
843 buf, MAX_PATH, filename);
844 ok(ret == 4, "Expected 4, got %d\n", ret);
845 ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
847 /* Existing section with no keys in an existing file */
848 memset(buf, 0xc,sizeof(buf));
849 SetLastError(0xdeadbeef);
850 ret=GetPrivateProfileStringA("section2", "DoesntExist", "",
851 buf, MAX_PATH, filename);
852 ok( ret == 0, "expected return size 0, got %d\n", ret );
853 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
855 ok( GetLastError() == 0xdeadbeef ||
856 GetLastError() == ERROR_FILE_NOT_FOUND /* Win 7 */,
857 "expected 0xdeadbeef or ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
861 DeleteFileA(filename);
864 static BOOL check_binary_file_data(LPCSTR path, const VOID *data, DWORD size)
870 file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
871 if (file == INVALID_HANDLE_VALUE)
874 if(size != GetFileSize(file, NULL) )
880 ret = ReadFile(file, buf, size, &size, NULL);
885 return !memcmp(buf, data, size);
888 static BOOL check_file_data(LPCSTR path, LPCSTR data)
890 return check_binary_file_data(path, data, lstrlenA(data));
893 static void test_WritePrivateProfileString(void)
900 SetLastError(0xdeadbeef);
901 ret = WritePrivateProfileStringW(NULL, NULL, NULL, NULL);
902 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
904 /* Win9x/WinME needs (variable) timeouts between tests and even long timeouts don't
905 * guarantee a correct result.
906 * Win9x/WinMe also produces different ini files where there is always a newline before
907 * a section start (except for the first one).
909 win_skip("WritePrivateProfileString on Win9x/WinME is hard to test reliably\n");
913 GetTempPathA(MAX_PATH, temp);
914 GetTempFileNameA(temp, "wine", 0, path);
917 /* path is not created yet */
920 SetLastError(0xdeadbeef);
921 ret = WritePrivateProfileStringA(NULL, "key", "string", path);
922 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
923 ok(GetLastError() == ERROR_FILE_NOT_FOUND ||
924 broken(GetLastError() == ERROR_INVALID_PARAMETER) || /* NT4 */
925 broken(GetLastError() == 0xdeadbeef), /* Win9x and WinME */
926 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
927 ok(GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES,
928 "Expected path to not exist\n");
930 GetTempFileNameA(temp, "wine", 0, path);
932 /* NULL lpAppName, path exists */
934 SetLastError(0xdeadbeef);
935 ret = WritePrivateProfileStringA(NULL, "key", "string", path);
936 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
937 ok(GetLastError() == ERROR_FILE_NOT_FOUND ||
938 broken(GetLastError() == ERROR_INVALID_PARAMETER) || /* NT4 */
939 broken(GetLastError() == 0xdeadbeef), /* Win9x and WinME */
940 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
941 ok(check_file_data(path, data), "File doesn't match\n");
946 /* empty lpAppName, crashes on NT4 and higher */
949 ret = WritePrivateProfileStringA("", "key", "string", path);
950 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
951 ok(check_file_data(path, data), "File doesn't match\n");
957 ret = WritePrivateProfileStringA("App", NULL, "string", path);
958 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
961 ok(check_file_data(path, data), "File doesn't match\n");
967 /* empty lpKeyName, crashes on NT4 and higher */
970 ret = WritePrivateProfileStringA("App", "", "string", path);
971 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
974 ok(check_file_data(path, data), "File doesn't match\n");
981 ret = WritePrivateProfileStringA("App", "key", NULL, path);
982 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
985 ok(check_file_data(path, data) ||
986 (broken(GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES)), /* Win9x and WinME */
987 "File doesn't match\n");
994 ret = WritePrivateProfileStringA("App", "key", "", path);
996 broken(!ret), /* Win9x and WinME */
997 "Expected TRUE, got %d\n", ret);
998 ok(check_file_data(path, data) ||
999 (broken(GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES)), /* Win9x and WinME */
1000 "File doesn't match\n");
1003 /* empty lpFileName */
1004 SetLastError(0xdeadbeef);
1005 ret = WritePrivateProfileStringA("App", "key", "string", "");
1006 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
1007 ok(GetLastError() == ERROR_ACCESS_DENIED ||
1008 broken(GetLastError() == ERROR_PATH_NOT_FOUND), /* Win9x and WinME */
1009 "Expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
1011 /* The resulting file will be X:\\%WINDIR%\\win1.tmp */
1012 GetWindowsDirectoryA(temp, MAX_PATH);
1013 GetTempFileNameA(temp, "win", 1, path);
1016 /* relative path in lpFileName */
1019 ret = WritePrivateProfileStringA("App", "key", "string", "win1.tmp");
1020 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1021 ok(check_file_data(path, data), "File doesn't match\n");
1024 GetTempPathA(MAX_PATH, temp);
1025 GetTempFileNameA(temp, "wine", 0, path);
1027 /* build up an INI file */
1028 WritePrivateProfileStringA("App1", "key1", "string1", path);
1029 WritePrivateProfileStringA("App1", "key2", "string2", path);
1030 WritePrivateProfileStringA("App1", "key3", "string3", path);
1031 WritePrivateProfileStringA("App2", "key4", "string4", path);
1033 /* make an addition and verify the INI */
1042 ret = WritePrivateProfileStringA("App3", "key5", "string5", path);
1043 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1044 ok(check_file_data(path, data), "File doesn't match\n");
1046 /* lpString is NULL, key2 key is deleted */
1054 ret = WritePrivateProfileStringA("App1", "key2", NULL, path);
1055 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1056 ok(check_file_data(path, data), "File doesn't match\n");
1058 /* try to delete key2 again */
1066 ret = WritePrivateProfileStringA("App1", "key2", NULL, path);
1067 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1068 ok(check_file_data(path, data), "File doesn't match\n");
1070 /* lpKeyName is NULL, App1 section is deleted */
1075 ret = WritePrivateProfileStringA("App1", NULL, "string1", path);
1076 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1077 ok(check_file_data(path, data), "File doesn't match\n");
1079 /* lpString is not needed to delete a section */
1082 ret = WritePrivateProfileStringA("App2", NULL, NULL, path);
1083 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1084 ok(check_file_data(path, data), "File doesn't match\n");
1086 /* leave just the section */
1087 data = "[App3]\r\n";
1088 ret = WritePrivateProfileStringA("App3", "key5", NULL, path);
1089 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1090 ok(check_file_data(path, data), "File doesn't match\n");
1093 /* NULLs in file before first section. Should be preserved in output */
1094 data = "Data \0 before \0 first \0 section" /* 31 bytes */
1095 "\r\n[section1]\r\n" /* 14 bytes */
1096 "key1=string1\r\n"; /* 14 bytes */
1097 GetTempFileNameA(temp, "wine", 0, path);
1098 create_test_file(path, data, 31);
1099 ret = WritePrivateProfileStringA("section1", "key1", "string1", path);
1100 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1102 ok( check_binary_file_data(path, data, 59) ||
1103 broken( check_binary_file_data(path, /* Windows 9x */
1104 "Data \0 before \0 first \0 section" /* 31 bytes */
1105 "\r\n\r\n[section1]\r\n" /* 14 bytes */
1106 "key1=string1" /* 14 bytes */
1107 , 59)), "File doesn't match\n");
1114 test_profile_string();
1115 test_profile_sections();
1116 test_profile_sections_names();
1117 test_profile_existing();
1118 test_profile_delete_on_close();
1119 test_profile_refresh();
1120 test_GetPrivateProfileString(
1123 "name2=\"val2\"\r\n"
1128 test_GetPrivateProfileString(
1136 test_WritePrivateProfileString();