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)
100 /* test that lines without an '=' will not be enumerated */
101 /* in the case below, name2 is a key while name3 is not. */
102 char content
[]="[s]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n";
103 DeleteFileA( TESTFILE2
);
104 h
= CreateFileA( TESTFILE2
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
105 FILE_ATTRIBUTE_NORMAL
, NULL
);
106 ok( h
!= INVALID_HANDLE_VALUE
, " cannot create %s\n", TESTFILE2
);
107 if( h
== INVALID_HANDLE_VALUE
) return;
108 WriteFile( h
, content
, sizeof(content
), &count
, NULL
);
111 /* enumerate the keys */
112 ret
=GetPrivateProfileStringA( "s", NULL
, "", buf
, sizeof(buf
),
114 for( p
= buf
+ strlen(buf
) + 1; *p
;p
+= strlen(p
)+1)
117 ok( ret
== 18 && !strcmp( buf
, "name1,name2,name4"), "wrong keys returned(%d): %s\n", ret
,
120 /* add a new key to test that the file is quite usable */
121 WritePrivateProfileStringA( "s", "name5", "val5", TESTFILE2
);
122 ret
=GetPrivateProfileStringA( "s", NULL
, "", buf
, sizeof(buf
),
124 for( p
= buf
+ strlen(buf
) + 1; *p
;p
+= strlen(p
)+1)
126 ok( ret
== 24 && !strcmp( buf
, "name1,name2,name4,name5"), "wrong keys returned(%d): %s\n",
129 DeleteFileA( TESTFILE2
);
132 static void test_profile_sections(void)
139 static const char content
[]="[section1]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n[section2]\r\n";
140 static const char testfile4
[]=".\\testwine4.ini";
141 BOOL on_win98
= FALSE
;
143 DeleteFileA( testfile4
);
144 h
= CreateFileA( testfile4
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
145 ok( h
!= INVALID_HANDLE_VALUE
, " cannot create %s\n", testfile4
);
146 if( h
== INVALID_HANDLE_VALUE
) return;
147 WriteFile( h
, content
, sizeof(content
), &count
, NULL
);
150 /* Some parameter checking */
151 SetLastError(0xdeadbeef);
152 ret
= GetPrivateProfileSectionA( NULL
, NULL
, 0, NULL
);
153 ok( ret
== 0, "expected return size 0, got %d\n", ret
);
154 ok( GetLastError() == ERROR_INVALID_PARAMETER
||
155 GetLastError() == 0xdeadbeef /* Win98 */,
156 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
157 if (GetLastError() == 0xdeadbeef) on_win98
= TRUE
;
159 SetLastError(0xdeadbeef);
160 ret
= GetPrivateProfileSectionA( NULL
, NULL
, 0, testfile4
);
161 ok( ret
== 0, "expected return size 0, got %d\n", ret
);
162 ok( GetLastError() == ERROR_INVALID_PARAMETER
||
163 GetLastError() == 0xdeadbeef /* Win98 */,
164 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
168 SetLastError(0xdeadbeef);
169 ret
= GetPrivateProfileSectionA( "section1", NULL
, 0, testfile4
);
170 ok( ret
== 0, "expected return size 0, got %d\n", ret
);
171 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
174 SetLastError(0xdeadbeef);
175 ret
= GetPrivateProfileSectionA( NULL
, buf
, sizeof(buf
), testfile4
);
176 ok( ret
== 0, "expected return size 0, got %d\n", ret
);
177 ok( GetLastError() == ERROR_INVALID_PARAMETER
||
178 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
179 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
181 SetLastError(0xdeadbeef);
182 ret
= GetPrivateProfileSectionA( "section1", buf
, sizeof(buf
), NULL
);
183 ok( ret
== 0, "expected return size 0, got %d\n", ret
);
185 ok( GetLastError() == ERROR_FILE_NOT_FOUND
||
186 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
187 "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
189 /* Existing empty section with no keys */
190 SetLastError(0xdeadbeef);
191 ret
=GetPrivateProfileSectionA("section2", buf
, sizeof(buf
), testfile4
);
192 ok( ret
== 0, "expected return size 0, got %d\n", ret
);
193 ok( GetLastError() == ERROR_SUCCESS
||
194 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
195 "expected ERROR_SUCCESS, got %d\n", GetLastError());
197 /* Existing section with keys and values*/
198 SetLastError(0xdeadbeef);
199 ret
=GetPrivateProfileSectionA("section1", buf
, sizeof(buf
), testfile4
);
200 for( p
= buf
+ strlen(buf
) + 1; *p
;p
+= strlen(p
)+1)
202 ok( ret
== 35 && !strcmp( buf
, "name1=val1,name2=,name3,name4=val4"), "wrong section returned(%d): %s\n",
204 ok( buf
[ret
-1] == 0 && buf
[ret
] == 0, "returned buffer not terminated with double-null\n" );
205 ok( GetLastError() == ERROR_SUCCESS
||
206 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
207 "expected ERROR_SUCCESS, got %d\n", GetLastError());
209 DeleteFileA( testfile4
);
212 static void test_profile_sections_names(void)
219 static const char content
[]="[section1]\r\n[section2]\r\n[section3]\r\n";
220 static const char testfile3
[]=".\\testwine3.ini";
221 static const WCHAR testfile3W
[]={ '.','\\','t','e','s','t','w','i','n','e','3','.','i','n','i',0 };
222 static const WCHAR not_here
[] = {'.','\\','n','o','t','_','h','e','r','e','.','i','n','i',0};
223 DeleteFileA( testfile3
);
224 h
= CreateFileA( testfile3
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
225 FILE_ATTRIBUTE_NORMAL
, NULL
);
226 ok( h
!= INVALID_HANDLE_VALUE
, " cannot create %s\n", testfile3
);
227 if( h
== INVALID_HANDLE_VALUE
) return;
228 WriteFile( h
, content
, sizeof(content
), &count
, NULL
);
231 /* Test with sufficiently large buffer */
232 memset(buf
, 0xc, sizeof(buf
));
233 ret
= GetPrivateProfileSectionNamesA( buf
, 29, testfile3
);
235 broken(ret
== 28), /* Win9x, WinME */
236 "expected return size 27, got %d\n", ret
);
237 ok( (buf
[ret
-1] == 0 && buf
[ret
] == 0) ||
238 broken(buf
[ret
-1] == 0 && buf
[ret
-2] == 0), /* Win9x, WinME */
239 "returned buffer not terminated with double-null\n" );
241 /* Test with exactly fitting buffer */
242 memset(buf
, 0xc, sizeof(buf
));
243 ret
= GetPrivateProfileSectionNamesA( buf
, 28, testfile3
);
245 broken(ret
== 28), /* Win9x, WinME */
246 "expected return size 26, got %d\n", ret
);
248 ok( (buf
[ret
+1] == 0 && buf
[ret
] == 0) || /* W2K3 and higher */
249 broken(buf
[ret
+1] == 0xc && buf
[ret
] == 0) || /* NT4, W2K, WinXP */
250 broken(buf
[ret
-1] == 0 && buf
[ret
-2] == 0), /* Win9x, WinME */
251 "returned buffer not terminated with double-null\n" );
253 /* Test with a buffer too small */
254 memset(buf
, 0xc, sizeof(buf
));
255 ret
= GetPrivateProfileSectionNamesA( buf
, 27, testfile3
);
256 ok( ret
== 25, "expected return size 25, got %d\n", ret
);
257 /* Win9x and WinME only fills the buffer with complete section names (double-null terminated) */
258 count
= strlen("section1") + sizeof(CHAR
) + strlen("section2");
260 ok( (buf
[ret
+1] == 0 && buf
[ret
] == 0) ||
261 broken(buf
[count
] == 0 && buf
[count
+1] == 0), /* Win9x, WinME */
262 "returned buffer not terminated with double-null\n" );
264 /* Tests on nonexistent file */
265 memset(buf
, 0xc, sizeof(buf
));
266 ret
= GetPrivateProfileSectionNamesA( buf
, 10, ".\\not_here.ini" );
268 broken(ret
== 1), /* Win9x, WinME */
269 "expected return size 0, got %d\n", ret
);
270 ok( buf
[0] == 0, "returned buffer not terminated with null\n" );
271 ok( buf
[1] != 0, "returned buffer terminated with double-null\n" );
273 /* Test with sufficiently large buffer */
274 SetLastError(0xdeadbeef);
275 memset(bufW
, 0xcc, sizeof(bufW
));
276 ret
= GetPrivateProfileSectionNamesW( bufW
, 29, testfile3W
);
277 if (ret
== 0 && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
))
279 win_skip("GetPrivateProfileSectionNamesW is not implemented\n");
280 DeleteFileA( testfile3
);
283 ok( ret
== 27, "expected return size 27, got %d\n", ret
);
284 ok( bufW
[ret
-1] == 0 && bufW
[ret
] == 0, "returned buffer not terminated with double-null\n" );
286 /* Test with exactly fitting buffer */
287 memset(bufW
, 0xcc, sizeof(bufW
));
288 ret
= GetPrivateProfileSectionNamesW( bufW
, 28, testfile3W
);
289 ok( ret
== 26, "expected return size 26, got %d\n", ret
);
290 ok( (bufW
[ret
+1] == 0 && bufW
[ret
] == 0) || /* W2K3 and higher */
291 broken(bufW
[ret
+1] == 0xcccc && bufW
[ret
] == 0), /* NT4, W2K, WinXP */
292 "returned buffer not terminated with double-null\n" );
294 /* Test with a buffer too small */
295 memset(bufW
, 0xcc, sizeof(bufW
));
296 ret
= GetPrivateProfileSectionNamesW( bufW
, 27, testfile3W
);
297 ok( ret
== 25, "expected return size 25, got %d\n", ret
);
298 ok( bufW
[ret
+1] == 0 && bufW
[ret
] == 0, "returned buffer not terminated with double-null\n" );
300 DeleteFileA( testfile3
);
302 /* Tests on nonexistent file */
303 memset(bufW
, 0xcc, sizeof(bufW
));
304 ret
= GetPrivateProfileSectionNamesW( bufW
, 10, not_here
);
305 ok( ret
== 0, "expected return size 0, got %d\n", ret
);
306 ok( bufW
[0] == 0, "returned buffer not terminated with null\n" );
307 ok( bufW
[1] != 0, "returned buffer terminated with double-null\n" );
310 /* If the ini-file has already been opened with CreateFile, WritePrivateProfileString failed in wine with an error ERROR_SHARING_VIOLATION, some testing here */
311 static void test_profile_existing(void)
313 static const char *testfile1
= ".\\winesharing1.ini";
314 static const char *testfile2
= ".\\winesharing2.ini";
316 static const struct {
317 DWORD dwDesiredAccess
;
323 {GENERIC_READ
, FILE_SHARE_READ
, ERROR_SHARING_VIOLATION
, FALSE
},
324 {GENERIC_READ
, FILE_SHARE_WRITE
, ERROR_SHARING_VIOLATION
, TRUE
},
325 {GENERIC_WRITE
, FILE_SHARE_READ
, ERROR_SHARING_VIOLATION
, FALSE
},
326 {GENERIC_WRITE
, FILE_SHARE_WRITE
, ERROR_SHARING_VIOLATION
, TRUE
},
327 {GENERIC_READ
|GENERIC_WRITE
, FILE_SHARE_READ
, ERROR_SHARING_VIOLATION
, FALSE
},
328 {GENERIC_READ
|GENERIC_WRITE
, FILE_SHARE_WRITE
, ERROR_SHARING_VIOLATION
, TRUE
},
329 {GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, 0, FALSE
, ERROR_SHARING_VIOLATION
/* nt4 */},
330 {GENERIC_WRITE
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, 0, FALSE
, ERROR_SHARING_VIOLATION
/* nt4 */},
331 /*Thief demo (bug 5024) opens .ini file like this*/
332 {GENERIC_READ
|GENERIC_WRITE
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, 0, FALSE
, ERROR_SHARING_VIOLATION
/* nt4 */}
339 char buffer
[MAX_PATH
];
341 for (i
=0; i
< sizeof(pe
)/sizeof(pe
[0]); i
++)
343 h
= CreateFile(testfile1
, pe
[i
].dwDesiredAccess
, pe
[i
].dwShareMode
, NULL
,
344 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
345 ok(INVALID_HANDLE_VALUE
!= h
, "%d: CreateFile failed\n",i
);
346 SetLastError(0xdeadbeef);
348 ret
= WritePrivateProfileString(SECTION
, KEY
, "12345", testfile1
);
349 if (!pe
[i
].write_error
)
352 ok( broken(GetLastError() == pe
[i
].broken_error
),
353 "%d: WritePrivateProfileString failed with error %u\n", i
, GetLastError() );
355 size
= GetPrivateProfileString(SECTION
, KEY
, 0, buffer
, MAX_PATH
, testfile1
);
357 ok( size
== 5, "%d: test failed, number of characters copied: %d instead of 5\n", i
, size
);
359 ok( !size
, "%d: test failed, number of characters copied: %d instead of 0\n", i
, size
);
363 DWORD err
= GetLastError();
364 ok( !ret
, "%d: WritePrivateProfileString succeeded\n", i
);
366 ok( err
== pe
[i
].write_error
, "%d: WritePrivateProfileString failed with error %u/%u\n",
367 i
, err
, pe
[i
].write_error
);
369 size
= GetPrivateProfileString(SECTION
, KEY
, 0, buffer
, MAX_PATH
, testfile1
);
370 ok( !size
, "%d: test failed, number of characters copied: %d instead of 0\n", i
, size
);
373 ok( DeleteFile(testfile1
), "delete failed\n" );
376 h
= CreateFile(testfile2
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
377 sprintf( buffer
, "[%s]\r\n%s=123\r\n", SECTION
, KEY
);
378 ok( WriteFile( h
, buffer
, strlen(buffer
), &size
, NULL
), "failed to write\n" );
381 for (i
=0; i
< sizeof(pe
)/sizeof(pe
[0]); i
++)
383 h
= CreateFile(testfile2
, pe
[i
].dwDesiredAccess
, pe
[i
].dwShareMode
, NULL
,
384 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
385 ok(INVALID_HANDLE_VALUE
!= h
, "%d: CreateFile failed\n",i
);
386 SetLastError(0xdeadbeef);
387 ret
= GetPrivateProfileStringA(SECTION
, KEY
, NULL
, buffer
, MAX_PATH
, testfile2
);
388 /* Win9x and WinME returns 0 for all cases except the first one */
389 if (!pe
[i
].read_error
)
391 broken(!ret
&& GetLastError() == 0xdeadbeef), /* Win9x, WinME */
392 "%d: GetPrivateProfileString failed with error %u\n", i
, GetLastError() );
394 ok( !ret
, "%d: GetPrivateProfileString succeeded\n", i
);
397 ok( DeleteFile(testfile2
), "delete failed\n" );
400 static void test_profile_delete_on_close(void)
402 static CHAR testfile
[] = ".\\testwine5.ini";
405 static const char contents
[] = "[" SECTION
"]\n" KEY
"=123\n";
407 h
= CreateFile(testfile
, GENERIC_WRITE
, FILE_SHARE_READ
, NULL
,
408 CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
409 ok( WriteFile( h
, contents
, sizeof contents
- 1, &size
, NULL
),
410 "Cannot write test file: %x\n", GetLastError() );
411 ok( size
== sizeof contents
- 1, "Test file: partial write\n");
413 SetLastError(0xdeadbeef);
414 res
= GetPrivateProfileInt(SECTION
, KEY
, 0, testfile
);
416 broken(res
== 0 && GetLastError() == ERROR_SHARING_VIOLATION
), /* Win9x, WinME */
417 "Got %d instead of 123\n", res
);
419 /* This also deletes the file */
423 static void test_profile_refresh(void)
425 static CHAR testfile
[] = ".\\winetest4.ini";
428 static const char contents1
[] = "[" SECTION
"]\n" KEY
"=123\n";
429 static const char contents2
[] = "[" SECTION
"]\n" KEY
"=124\n";
431 h
= CreateFile(testfile
, GENERIC_WRITE
, FILE_SHARE_READ
, NULL
,
432 CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
433 ok( WriteFile( h
, contents1
, sizeof contents1
- 1, &size
, NULL
),
434 "Cannot write test file: %x\n", GetLastError() );
435 ok( size
== sizeof contents1
- 1, "Test file: partial write\n");
437 SetLastError(0xdeadbeef);
438 res
= GetPrivateProfileInt(SECTION
, KEY
, 0, testfile
);
440 broken(res
== 0 && GetLastError() == ERROR_SHARING_VIOLATION
), /* Win9x, WinME */
441 "Got %d instead of 123\n", res
);
445 /* Test proper invalidation of wine's profile file cache */
447 h
= CreateFile(testfile
, GENERIC_WRITE
, FILE_SHARE_READ
, NULL
,
448 CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
449 ok( WriteFile( h
, contents2
, sizeof contents2
- 1, &size
, NULL
),
450 "Cannot write test file: %x\n", GetLastError() );
451 ok( size
== sizeof contents2
- 1, "Test file: partial write\n");
453 SetLastError(0xdeadbeef);
454 res
= GetPrivateProfileInt(SECTION
, KEY
, 0, testfile
);
456 broken(res
== 0 && GetLastError() == 0xdeadbeef), /* Win9x, WinME */
457 "Got %d instead of 124\n", res
);
459 /* This also deletes the file */
463 static void create_test_file(LPCSTR name
, LPCSTR data
, DWORD size
)
468 hfile
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
469 ok(hfile
!= INVALID_HANDLE_VALUE
, "cannot create %s\n", name
);
470 WriteFile(hfile
, data
, size
, &count
, NULL
);
474 static BOOL
emptystr_ok(CHAR emptystr
[MAX_PATH
])
478 for(i
= 0;i
< MAX_PATH
;++i
)
481 trace("emptystr[%d] = %d\n",i
,emptystr
[i
]);
488 static void test_GetPrivateProfileString(const char *content
, const char *descript
)
492 CHAR def_val
[MAX_PATH
];
494 CHAR windir
[MAX_PATH
];
495 /* NT series crashes on r/o empty strings, so pass an r/w
496 empty string and check for modification */
497 CHAR emptystr
[MAX_PATH
] = "";
500 static const char filename
[] = ".\\winetest.ini";
502 trace("test_GetPrivateProfileStringA: %s\n", descript
);
504 if(!lstrcmpA(descript
, "CR only"))
506 SetLastError(0xdeadbeef);
507 ret
= GetPrivateProfileStringW(NULL
, NULL
, NULL
,
509 if (!ret
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
511 win_skip("Win9x and WinME don't handle 'CR only' correctly\n");
516 create_test_file(filename
, content
, lstrlenA(content
));
518 /* Run this test series with caching. Wine won't cache profile
519 files younger than 2.1 seconds. */
522 /* lpAppName is NULL */
523 memset(buf
, 0xc, sizeof(buf
));
524 lstrcpyA(buf
, "kumquat");
525 ret
= GetPrivateProfileStringA(NULL
, "name1", "default",
526 buf
, MAX_PATH
, filename
);
528 broken(ret
== 19), /* Win9x and WinME */
529 "Expected 18, got %d\n", ret
);
530 len
= lstrlenA("section1") + sizeof(CHAR
) + lstrlenA("section2") + 2 * sizeof(CHAR
);
531 ok(!memcmp(buf
, "section1\0section2\0\0", len
),
532 "Expected \"section1\\0section2\\0\\0\", got \"%s\"\n", buf
);
534 /* lpAppName is empty */
535 memset(buf
, 0xc, sizeof(buf
));
536 lstrcpyA(buf
, "kumquat");
537 ret
= GetPrivateProfileStringA(emptystr
, "name1", "default",
538 buf
, MAX_PATH
, filename
);
539 ok(ret
== 7, "Expected 7, got %d\n", ret
);
540 ok(!lstrcmpA(buf
, "default"), "Expected \"default\", got \"%s\"\n", buf
);
541 ok(emptystr_ok(emptystr
), "AppName modified\n");
543 /* lpAppName is missing */
544 memset(buf
, 0xc,sizeof(buf
));
545 lstrcpyA(buf
, "kumquat");
546 ret
= GetPrivateProfileStringA("notasection", "name1", "default",
547 buf
, MAX_PATH
, filename
);
548 ok(ret
== 7, "Expected 7, got %d\n", ret
);
549 ok(!lstrcmpA(buf
, "default"), "Expected \"default\", got \"%s\"\n", buf
);
551 /* lpAppName is empty, lpDefault is NULL */
552 memset(buf
, 0xc,sizeof(buf
));
553 lstrcpyA(buf
, "kumquat");
554 ret
= GetPrivateProfileStringA(emptystr
, "name1", NULL
,
555 buf
, MAX_PATH
, filename
);
556 ok(ret
== 0, "Expected 0, got %d\n", ret
);
557 ok(!lstrcmpA(buf
, "") ||
558 broken(!lstrcmpA(buf
, "kumquat")), /* Win9x, WinME */
559 "Expected \"\", got \"%s\"\n", buf
);
560 ok(emptystr_ok(emptystr
), "AppName modified\n");
562 /* lpAppName is empty, lpDefault is empty */
563 memset(buf
, 0xc,sizeof(buf
));
564 lstrcpyA(buf
, "kumquat");
565 ret
= GetPrivateProfileStringA(emptystr
, "name1", "",
566 buf
, MAX_PATH
, filename
);
567 ok(ret
== 0, "Expected 0, got %d\n", ret
);
568 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
569 ok(emptystr_ok(emptystr
), "AppName modified\n");
571 /* lpAppName is empty, lpDefault has trailing blank characters */
572 memset(buf
, 0xc,sizeof(buf
));
573 lstrcpyA(buf
, "kumquat");
574 /* lpDefault must be writable (trailing blanks are removed inplace in win9x) */
575 lstrcpyA(def_val
, "default ");
576 ret
= GetPrivateProfileStringA(emptystr
, "name1", def_val
,
577 buf
, MAX_PATH
, filename
);
578 ok(ret
== 7, "Expected 7, got %d\n", ret
);
579 ok(!lstrcmpA(buf
, "default"), "Expected \"default\", got \"%s\"\n", buf
);
580 ok(emptystr_ok(emptystr
), "AppName modified\n");
582 /* lpAppName is empty, many blank characters in lpDefault */
583 memset(buf
, 0xc,sizeof(buf
));
584 lstrcpyA(buf
, "kumquat");
585 /* lpDefault must be writable (trailing blanks are removed inplace in win9x) */
586 lstrcpyA(def_val
, "one two ");
587 ret
= GetPrivateProfileStringA(emptystr
, "name1", def_val
,
588 buf
, MAX_PATH
, filename
);
589 ok(ret
== 7, "Expected 7, got %d\n", ret
);
590 ok(!lstrcmpA(buf
, "one two"), "Expected \"one two\", got \"%s\"\n", buf
);
591 ok(emptystr_ok(emptystr
), "AppName modified\n");
593 /* lpAppName is empty, blank character but not trailing in lpDefault */
594 memset(buf
, 0xc,sizeof(buf
));
595 lstrcpyA(buf
, "kumquat");
596 ret
= GetPrivateProfileStringA(emptystr
, "name1", "one two",
597 buf
, MAX_PATH
, filename
);
598 ok(ret
== 7, "Expected 7, got %d\n", ret
);
599 ok(!lstrcmpA(buf
, "one two"), "Expected \"one two\", got \"%s\"\n", buf
);
600 ok(emptystr_ok(emptystr
), "AppName modified\n");
602 /* lpKeyName is NULL */
603 memset(buf
, 0xc,sizeof(buf
));
604 lstrcpyA(buf
, "kumquat");
605 ret
= GetPrivateProfileStringA("section1", NULL
, "default",
606 buf
, MAX_PATH
, filename
);
607 ok(ret
== 18, "Expected 18, got %d\n", ret
);
608 ok(!memcmp(buf
, "name1\0name2\0name4\0", ret
+ 1),
609 "Expected \"name1\\0name2\\0name4\\0\", got \"%s\"\n", buf
);
611 /* lpKeyName is empty */
612 memset(buf
, 0xc,sizeof(buf
));
613 lstrcpyA(buf
, "kumquat");
614 ret
= GetPrivateProfileStringA("section1", emptystr
, "default",
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
), "KeyName modified\n");
620 /* lpKeyName is missing */
621 memset(buf
, 0xc,sizeof(buf
));
622 lstrcpyA(buf
, "kumquat");
623 ret
= GetPrivateProfileStringA("section1", "notakey", "default",
624 buf
, MAX_PATH
, filename
);
625 ok(ret
== 7, "Expected 7, got %d\n", ret
);
626 ok(!lstrcmpA(buf
, "default"), "Expected \"default\", got \"%s\"\n", buf
);
628 /* lpKeyName is empty, lpDefault is NULL */
629 memset(buf
, 0xc,sizeof(buf
));
630 lstrcpyA(buf
, "kumquat");
631 ret
= GetPrivateProfileStringA("section1", emptystr
, NULL
,
632 buf
, MAX_PATH
, filename
);
633 ok(ret
== 0, "Expected 0, got %d\n", ret
);
634 ok(!lstrcmpA(buf
, "") ||
635 broken(!lstrcmpA(buf
, "kumquat")), /* Win9x, WinME */
636 "Expected \"\", got \"%s\"\n", buf
);
637 ok(emptystr_ok(emptystr
), "KeyName modified\n");
639 /* lpKeyName is empty, lpDefault is empty */
640 memset(buf
, 0xc,sizeof(buf
));
641 lstrcpyA(buf
, "kumquat");
642 ret
= GetPrivateProfileStringA("section1", emptystr
, "",
643 buf
, MAX_PATH
, filename
);
644 ok(ret
== 0, "Expected 0, got %d\n", ret
);
645 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
646 ok(emptystr_ok(emptystr
), "KeyName modified\n");
648 /* lpKeyName is empty, lpDefault has trailing blank characters */
649 memset(buf
, 0xc,sizeof(buf
));
650 lstrcpyA(buf
, "kumquat");
651 /* lpDefault must be writable (trailing blanks are removed inplace in win9x) */
652 lstrcpyA(def_val
, "default ");
653 ret
= GetPrivateProfileStringA("section1", emptystr
, def_val
,
654 buf
, MAX_PATH
, filename
);
655 ok(ret
== 7, "Expected 7, got %d\n", ret
);
656 ok(!lstrcmpA(buf
, "default"), "Expected \"default\", got \"%s\"\n", buf
);
657 ok(emptystr_ok(emptystr
), "KeyName modified\n");
661 /* lpReturnedString is NULL */
662 ret
= GetPrivateProfileStringA("section1", "name1", "default",
663 NULL
, MAX_PATH
, filename
);
666 /* lpFileName is NULL */
667 memset(buf
, 0xc,sizeof(buf
));
668 lstrcpyA(buf
, "kumquat");
669 ret
= GetPrivateProfileStringA("section1", "name1", "default",
670 buf
, MAX_PATH
, NULL
);
672 broken(ret
== 0), /* Win9x, WinME */
673 "Expected 7, got %d\n", ret
);
674 ok(!lstrcmpA(buf
, "default") ||
675 broken(!lstrcmpA(buf
, "kumquat")), /* Win9x, WinME */
676 "Expected \"default\", got \"%s\"\n", buf
);
678 /* lpFileName is empty */
679 memset(buf
, 0xc,sizeof(buf
));
680 lstrcpyA(buf
, "kumquat");
681 ret
= GetPrivateProfileStringA("section1", "name1", "default",
683 ok(ret
== 7, "Expected 7, got %d\n", ret
);
684 ok(!lstrcmpA(buf
, "default"), "Expected \"default\", got \"%s\"\n", buf
);
686 /* lpFileName is nonexistent */
687 memset(buf
, 0xc,sizeof(buf
));
688 lstrcpyA(buf
, "kumquat");
689 ret
= GetPrivateProfileStringA("section1", "name1", "default",
690 buf
, MAX_PATH
, "nonexistent");
691 ok(ret
== 7, "Expected 7, got %d\n", ret
);
692 ok(!lstrcmpA(buf
, "default"), "Expected \"default\", got \"%s\"\n", buf
);
695 memset(buf
, 0xc,sizeof(buf
));
696 lstrcpyA(buf
, "kumquat");
697 ret
= GetPrivateProfileStringA("section1", "name1", "default",
699 ok(ret
== 0, "Expected 0, got %d\n", ret
);
700 ok(!lstrcmpA(buf
, "kumquat"), "Expected buf to be unchanged, got \"%s\"\n", buf
);
702 /* nSize is exact size of output */
703 memset(buf
, 0xc,sizeof(buf
));
704 lstrcpyA(buf
, "kumquat");
705 ret
= GetPrivateProfileStringA("section1", "name1", "default",
707 ok(ret
== 3, "Expected 3, got %d\n", ret
);
708 ok(!lstrcmpA(buf
, "val"), "Expected \"val\", got \"%s\"\n", buf
);
710 /* nSize has room for NULL terminator */
711 memset(buf
, 0xc,sizeof(buf
));
712 lstrcpyA(buf
, "kumquat");
713 ret
= GetPrivateProfileStringA("section1", "name1", "default",
715 ok(ret
== 4, "Expected 4, got %d\n", ret
);
716 ok(!lstrcmpA(buf
, "val1"), "Expected \"val1\", got \"%s\"\n", buf
);
718 /* output is 1 character */
719 memset(buf
, 0xc,sizeof(buf
));
720 lstrcpyA(buf
, "kumquat");
721 ret
= GetPrivateProfileStringA("section1", "name4", "default",
722 buf
, MAX_PATH
, filename
);
723 ok(ret
== 1, "Expected 1, got %d\n", ret
);
724 ok(!lstrcmpA(buf
, "a"), "Expected \"a\", got \"%s\"\n", buf
);
726 /* output is 1 character, no room for NULL terminator */
727 memset(buf
, 0xc,sizeof(buf
));
728 lstrcpyA(buf
, "kumquat");
729 ret
= GetPrivateProfileStringA("section1", "name4", "default",
731 ok(ret
== 0, "Expected 0, got %d\n", ret
);
732 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
734 /* lpAppName is NULL, not enough room for final section name */
735 memset(buf
, 0xc,sizeof(buf
));
736 lstrcpyA(buf
, "kumquat");
737 ret
= GetPrivateProfileStringA(NULL
, "name1", "default",
739 ok(ret
== 14, "Expected 14, got %d\n", ret
);
740 len
= lstrlenA("section1") + 2 * sizeof(CHAR
);
742 ok(!memcmp(buf
, "section1\0secti\0\0", ret
+ 2) ||
743 broken(!memcmp(buf
, "section1\0\0", len
)), /* Win9x, WinME */
744 "Expected \"section1\\0secti\\0\\0\", got \"%s\"\n", buf
);
746 /* lpKeyName is NULL, not enough room for final key name */
747 memset(buf
, 0xc,sizeof(buf
));
748 lstrcpyA(buf
, "kumquat");
749 ret
= GetPrivateProfileStringA("section1", NULL
, "default",
751 ok(ret
== 14, "Expected 14, got %d\n", ret
);
753 ok(!memcmp(buf
, "name1\0name2\0na\0\0", ret
+ 2) ||
754 broken(!memcmp(buf
, "name1\0name2\0n\0\0", ret
+ 1)), /* Win9x, WinME */
755 "Expected \"name1\\0name2\\0na\\0\\0\", got \"%s\"\n", buf
);
757 /* key value has quotation marks which are stripped */
758 memset(buf
, 0xc,sizeof(buf
));
759 lstrcpyA(buf
, "kumquat");
760 ret
= GetPrivateProfileStringA("section1", "name2", "default",
761 buf
, MAX_PATH
, filename
);
762 ok(ret
== 4, "Expected 4, got %d\n", ret
);
763 ok(!lstrcmpA(buf
, "val2"), "Expected \"val2\", got \"%s\"\n", buf
);
765 /* case does not match */
766 memset(buf
, 0xc,sizeof(buf
));
767 lstrcpyA(buf
, "kumquat");
768 ret
= GetPrivateProfileStringA("section1", "NaMe1", "default",
769 buf
, MAX_PATH
, filename
);
770 ok(ret
== 4, "Expected 4, got %d\n", ret
);
771 ok(!lstrcmpA(buf
, "val1"), "Expected \"val1\", got \"%s\"\n", buf
);
773 /* only filename is used */
774 memset(buf
, 0xc,sizeof(buf
));
775 lstrcpyA(buf
, "kumquat");
776 ret
= GetPrivateProfileStringA("section1", "NaMe1", "default",
777 buf
, MAX_PATH
, "winetest.ini");
778 ok(ret
== 7, "Expected 7, got %d\n", ret
);
779 ok(!lstrcmpA(buf
, "default"), "Expected \"default\", got \"%s\"\n", buf
);
781 GetWindowsDirectoryA(windir
, MAX_PATH
);
782 SetLastError(0xdeadbeef);
783 ret
= GetTempFileNameA(windir
, "pre", 0, path
);
784 if (!ret
&& GetLastError() == ERROR_ACCESS_DENIED
)
786 skip("Not allowed to create a file in the Windows directory\n");
787 DeleteFileA(filename
);
790 tempfile
= strrchr(path
, '\\') + 1;
791 create_test_file(path
, content
, lstrlenA(content
));
793 /* only filename is used, file exists in windows directory */
794 memset(buf
, 0xc,sizeof(buf
));
795 lstrcpyA(buf
, "kumquat");
796 ret
= GetPrivateProfileStringA("section1", "NaMe1", "default",
797 buf
, MAX_PATH
, tempfile
);
798 ok(ret
== 4, "Expected 4, got %d\n", ret
);
799 ok(!lstrcmpA(buf
, "val1"), "Expected \"val1\", got \"%s\"\n", buf
);
801 /* successful case */
802 memset(buf
, 0xc,sizeof(buf
));
803 lstrcpyA(buf
, "kumquat");
804 ret
= GetPrivateProfileStringA("section1", "name1", "default",
805 buf
, MAX_PATH
, filename
);
806 ok(ret
== 4, "Expected 4, got %d\n", ret
);
807 ok(!lstrcmpA(buf
, "val1"), "Expected \"val1\", got \"%s\"\n", buf
);
809 /* Existing section with no keys in an existing file */
810 memset(buf
, 0xc,sizeof(buf
));
811 SetLastError(0xdeadbeef);
812 ret
=GetPrivateProfileStringA("section2", "DoesntExist", "",
813 buf
, MAX_PATH
, filename
);
814 ok( ret
== 0, "expected return size 0, got %d\n", ret
);
815 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
817 ok( GetLastError() == 0xdeadbeef , "expected 0xdeadbeef, got %d\n",
822 DeleteFileA(filename
);
825 static DWORD timeout
= 0;
827 static BOOL
check_binary_file_data(LPCSTR path
, const VOID
*data
, DWORD size
)
833 /* Sleep() is needed on Win9x and WinME */
837 file
= CreateFileA(path
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, 0);
838 if (file
== INVALID_HANDLE_VALUE
)
841 if(size
!= GetFileSize(file
, NULL
) )
847 ret
= ReadFile(file
, buf
, size
, &size
, NULL
);
852 return !memcmp(buf
, data
, size
);
855 static BOOL
check_file_data(LPCSTR path
, LPCSTR data
)
857 return check_binary_file_data(path
, data
, lstrlenA(data
));
860 static void test_WritePrivateProfileString(void)
867 GetTempPathA(MAX_PATH
, temp
);
868 GetTempFileNameA(temp
, "wine", 0, path
);
871 /* path is not created yet */
874 SetLastError(0xdeadbeef);
875 ret
= WritePrivateProfileStringA(NULL
, "key", "string", path
);
876 ok(ret
== FALSE
, "Expected FALSE, got %d\n", ret
);
877 ok(GetLastError() == ERROR_FILE_NOT_FOUND
||
878 broken(GetLastError() == ERROR_INVALID_PARAMETER
) || /* NT4 */
879 broken(GetLastError() == 0xdeadbeef), /* Win9x and WinME */
880 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
881 if (GetLastError() == 0xdeadbeef)
883 ok(GetFileAttributesA(path
) == INVALID_FILE_ATTRIBUTES
,
884 "Expected path to not exist\n");
886 GetTempFileNameA(temp
, "wine", 0, path
);
888 /* NULL lpAppName, path exists */
890 SetLastError(0xdeadbeef);
891 ret
= WritePrivateProfileStringA(NULL
, "key", "string", path
);
892 ok(ret
== FALSE
, "Expected FALSE, got %d\n", ret
);
893 ok(GetLastError() == ERROR_FILE_NOT_FOUND
||
894 broken(GetLastError() == ERROR_INVALID_PARAMETER
) || /* NT4 */
895 broken(GetLastError() == 0xdeadbeef), /* Win9x and WinME */
896 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
897 ok(check_file_data(path
, data
), "File doesn't match\n");
902 /* empty lpAppName, crashes on NT4 and higher */
905 ret
= WritePrivateProfileStringA("", "key", "string", path
);
906 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
907 ok(check_file_data(path
, data
), "File doesn't match\n");
913 ret
= WritePrivateProfileStringA("App", NULL
, "string", path
);
914 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
917 ok(check_file_data(path
, data
), "File doesn't match\n");
923 /* empty lpKeyName, crashes on NT4 and higher */
926 ret
= WritePrivateProfileStringA("App", "", "string", path
);
927 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
930 ok(check_file_data(path
, data
), "File doesn't match\n");
937 ret
= WritePrivateProfileStringA("App", "key", NULL
, path
);
938 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
941 ok(check_file_data(path
, data
) ||
942 (broken(GetFileAttributesA(path
) == INVALID_FILE_ATTRIBUTES
)), /* Win9x and WinME */
943 "File doesn't match\n");
950 ret
= WritePrivateProfileStringA("App", "key", "", path
);
952 broken(!ret
), /* Win9x and WinME */
953 "Expected TRUE, got %d\n", ret
);
954 ok(check_file_data(path
, data
) ||
955 (broken(GetFileAttributesA(path
) == INVALID_FILE_ATTRIBUTES
)), /* Win9x and WinME */
956 "File doesn't match\n");
959 /* empty lpFileName */
960 SetLastError(0xdeadbeef);
961 ret
= WritePrivateProfileStringA("App", "key", "string", "");
962 ok(ret
== FALSE
, "Expected FALSE, got %d\n", ret
);
963 ok(GetLastError() == ERROR_ACCESS_DENIED
||
964 broken(GetLastError() == ERROR_PATH_NOT_FOUND
), /* Win9x and WinME */
965 "Expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
967 /* The resulting file will be X:\\%WINDIR%\\win1.tmp */
968 GetWindowsDirectoryA(temp
, MAX_PATH
);
969 GetTempFileNameA(temp
, "win", 1, path
);
972 /* relative path in lpFileName */
975 ret
= WritePrivateProfileStringA("App", "key", "string", "win1.tmp");
976 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
977 ok(check_file_data(path
, data
), "File doesn't match\n");
980 GetTempPathA(MAX_PATH
, temp
);
981 GetTempFileNameA(temp
, "wine", 0, path
);
983 /* build up an INI file */
984 WritePrivateProfileStringA("App1", "key1", "string1", path
);
985 WritePrivateProfileStringA("App1", "key2", "string2", path
);
986 WritePrivateProfileStringA("App1", "key3", "string3", path
);
987 WritePrivateProfileStringA("App2", "key4", "string4", path
);
989 /* make an addition and verify the INI */
998 ret
= WritePrivateProfileStringA("App3", "key5", "string5", path
);
999 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1000 ok(check_file_data(path
, data
), "File doesn't match\n");
1002 /* lpString is NULL, key2 key is deleted */
1010 ret
= WritePrivateProfileStringA("App1", "key2", NULL
, path
);
1011 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1012 ok(check_file_data(path
, data
), "File doesn't match\n");
1014 /* try to delete key2 again */
1022 ret
= WritePrivateProfileStringA("App1", "key2", NULL
, path
);
1023 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1024 ok(check_file_data(path
, data
), "File doesn't match\n");
1026 /* lpKeyName is NULL, App1 section is deleted */
1031 ret
= WritePrivateProfileStringA("App1", NULL
, "string1", path
);
1032 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1033 ok(check_file_data(path
, data
), "File doesn't match\n");
1035 /* lpString is not needed to delete a section */
1038 ret
= WritePrivateProfileStringA("App2", NULL
, NULL
, path
);
1039 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1040 ok(check_file_data(path
, data
), "File doesn't match\n");
1042 /* leave just the section */
1043 data
= "[App3]\r\n";
1044 ret
= WritePrivateProfileStringA("App3", "key5", NULL
, path
);
1045 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1046 ok(check_file_data(path
, data
), "File doesn't match\n");
1049 /* NULLs in file before first section. Should be preserved in output */
1050 data
= "Data \0 before \0 first \0 section" /* 31 bytes */
1051 "\r\n[section1]\r\n" /* 14 bytes */
1052 "key1=string1\r\n"; /* 14 bytes */
1053 GetTempFileNameA(temp
, "wine", 0, path
);
1054 create_test_file(path
, data
, 31);
1055 ret
= WritePrivateProfileStringA("section1", "key1", "string1", path
);
1056 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1058 ok( check_binary_file_data(path
, data
, 59) ||
1059 broken( check_binary_file_data(path
, /* Windows 9x */
1060 "Data \0 before \0 first \0 section" /* 31 bytes */
1061 "\r\n\r\n[section1]\r\n" /* 14 bytes */
1062 "key1=string1" /* 14 bytes */
1063 , 59)), "File doesn't match\n");
1070 test_profile_string();
1071 test_profile_sections();
1072 test_profile_sections_names();
1073 test_profile_existing();
1074 test_profile_delete_on_close();
1075 test_profile_refresh();
1076 test_GetPrivateProfileString(
1079 "name2=\"val2\"\r\n"
1084 test_GetPrivateProfileString(
1092 test_WritePrivateProfileString();