ret=GetPrivateProfileStringW(emptyW, keyW, emptyW, bufW,
sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
todo_wine
+ ok(ret == 13, "expected 13, got %u\n", ret);
+ todo_wine
ok(!lstrcmpW(valsectionW,bufW), "expected %s, got %s\n",
wine_dbgstr_w(valsectionW), wine_dbgstr_w(bufW) );
ret=GetPrivateProfileStringW(sW, emptyW, emptyW, bufW,
sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
todo_wine
+ ok(ret == 10, "expected 10, got %u\n", ret);
+ todo_wine
ok(!lstrcmpW(valnokeyW,bufW), "expected %s, got %s\n",
wine_dbgstr_w(valnokeyW), wine_dbgstr_w(bufW) );
ok( (buf[ret-1] == 0 && buf[ret] == 0) ||
broken(buf[ret-1] == 0 && buf[ret-2] == 0), /* Win9x, WinME */
"returned buffer not terminated with double-null\n" );
-
+
/* Test with exactly fitting buffer */
memset(buf, 0xc, sizeof(buf));
ret = GetPrivateProfileSectionNamesA( buf, 28, testfile3 );
broken(buf[ret+1] == 0xc && buf[ret] == 0) || /* NT4, W2K, WinXP */
broken(buf[ret-1] == 0 && buf[ret-2] == 0), /* Win9x, WinME */
"returned buffer not terminated with double-null\n" );
-
+
/* Test with a buffer too small */
memset(buf, 0xc, sizeof(buf));
ret = GetPrivateProfileSectionNamesA( buf, 27, testfile3 );
ok( (buf[ret+1] == 0 && buf[ret] == 0) ||
broken(buf[count] == 0 && buf[count+1] == 0), /* Win9x, WinME */
"returned buffer not terminated with double-null\n" );
-
+
/* Tests on nonexistent file */
memset(buf, 0xc, sizeof(buf));
ret = GetPrivateProfileSectionNamesA( buf, 10, ".\\not_here.ini" );
ok( (bufW[ret+1] == 0 && bufW[ret] == 0) || /* W2K3 and higher */
broken(bufW[ret+1] == 0xcccc && bufW[ret] == 0), /* NT4, W2K, WinXP */
"returned buffer not terminated with double-null\n" );
-
+
/* Test with a buffer too small */
memset(bufW, 0xcc, sizeof(bufW));
ret = GetPrivateProfileSectionNamesW( bufW, 27, testfile3W );
h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
- ok( WriteFile( h, contents, sizeof contents - 1, &size, NULL ),
- "Cannot write test file: %x\n", GetLastError() );
+ res = WriteFile( h, contents, sizeof contents - 1, &size, NULL );
+ ok( res, "Cannot write test file: %x\n", GetLastError() );
ok( size == sizeof contents - 1, "Test file: partial write\n");
SetLastError(0xdeadbeef);
h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
- ok( WriteFile( h, contents1, sizeof contents1 - 1, &size, NULL ),
- "Cannot write test file: %x\n", GetLastError() );
+ res = WriteFile( h, contents1, sizeof contents1 - 1, &size, NULL );
+ ok( res, "Cannot write test file: %x\n", GetLastError() );
ok( size == sizeof contents1 - 1, "Test file: partial write\n");
SetLastError(0xdeadbeef);
h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
- ok( WriteFile( h, contents2, sizeof contents2 - 1, &size, NULL ),
- "Cannot write test file: %x\n", GetLastError() );
+ res = WriteFile( h, contents2, sizeof contents2 - 1, &size, NULL );
+ ok( res, "Cannot write test file: %x\n", GetLastError() );
ok( size == sizeof contents2 - 1, "Test file: partial write\n");
SetLastError(0xdeadbeef);
/* This also deletes the file */
CloseHandle(h);
+
+ /* Cache must be invalidated if file no longer exists and default must be returned */
+ SetLastError(0xdeadbeef);
+ res = GetPrivateProfileInt(SECTION, KEY, 421, testfile);
+ ok( res == 421 ||
+ broken(res == 0 && GetLastError() == 0xdeadbeef), /* Win9x, WinME */
+ "Got %d instead of 421\n", res);
}
static void create_test_file(LPCSTR name, LPCSTR data, DWORD size)