[KERNEL32_WINETEST]
[reactos.git] / rostests / winetests / kernel32 / profile.c
index e3f7156..211d0c6 100755 (executable)
@@ -146,6 +146,8 @@ static void test_profile_string(void)
     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) );
 
@@ -153,6 +155,8 @@ static void test_profile_string(void)
     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) );
 
@@ -444,8 +448,8 @@ static void test_profile_delete_on_close(void)
 
     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);
@@ -468,8 +472,8 @@ static void test_profile_refresh(void)
 
     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);
@@ -484,8 +488,8 @@ static void test_profile_refresh(void)
 
     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);
@@ -496,6 +500,13 @@ static void test_profile_refresh(void)
 
     /* 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)