Commit e8b260f0 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

reg/tests: Use the verify_key*() functions where possible.

parent ceebbfc1
...@@ -120,7 +120,7 @@ static void verify_key_nonexist_(unsigned line, HKEY key_base, const char *subke ...@@ -120,7 +120,7 @@ static void verify_key_nonexist_(unsigned line, HKEY key_base, const char *subke
static void test_add(void) static void test_add(void)
{ {
HKEY hkey, subkey; HKEY hkey;
LONG err; LONG err;
DWORD r, dword, type, size; DWORD r, dword, type, size;
char buffer[22]; char buffer[22];
...@@ -134,8 +134,7 @@ static void test_add(void) ...@@ -134,8 +134,7 @@ static void test_add(void)
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE); err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err); ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE);
ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r); run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
...@@ -167,18 +166,14 @@ static void test_add(void) ...@@ -167,18 +166,14 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r); run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r); ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE "\\keytest3", 0, KEY_READ, &subkey); verify_key(hkey, "keytest3");
ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err); err = RegDeleteKeyA(hkey, "keytest3");
RegCloseKey(subkey);
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest3");
ok(err == ERROR_SUCCESS, "got exit code %d\n", err); ok(err == ERROR_SUCCESS, "got exit code %d\n", err);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest4 /f", &r); run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest4 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r); ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE "\\keytest4", 0, KEY_READ, &subkey); verify_key(hkey, "keytest4");
ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err); err = RegDeleteKeyA(hkey, "keytest4");
RegCloseKey(subkey);
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest4");
ok(err == ERROR_SUCCESS, "got exit code %d\n", err); ok(err == ERROR_SUCCESS, "got exit code %d\n", err);
/* REG_NONE */ /* REG_NONE */
...@@ -545,15 +540,13 @@ static void test_delete(void) ...@@ -545,15 +540,13 @@ static void test_delete(void)
run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r); run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg_nonexist(hkey, "foo"); verify_reg_nonexist(hkey, "foo");
err = RegOpenKeyExA(hkey, "subkey", 0, KEY_READ, &hsubkey); verify_key(hkey, "subkey");
ok(err == ERROR_SUCCESS, "got %d\n", err);
RegCloseKey(hsubkey);
RegCloseKey(hkey); RegCloseKey(hkey);
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r); run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE);
ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r); run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
...@@ -1435,15 +1428,13 @@ static void test_import(void) ...@@ -1435,15 +1428,13 @@ static void test_import(void)
"[HKEY_CURRENT_USER\\" KEY_BASE "\\\n" "[HKEY_CURRENT_USER\\" KEY_BASE "\\\n"
"Subkey1]\n", &r); "Subkey1]\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
err = RegOpenKeyExA(hkey, "Subkey1", 0, KEY_READ, &subkey); todo_wine verify_key_nonexist(hkey, "Subkey1");
todo_wine ok(err == ERROR_FILE_NOT_FOUND, "got %d, expected 2\n", err);
test_import_str("REGEDIT4\n\n" test_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\n" "[HKEY_CURRENT_USER\\" KEY_BASE "\n"
"\\Subkey2]\n", &r); "\\Subkey2]\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
err = RegOpenKeyExA(hkey, "Subkey2", 0, KEY_READ, &subkey); todo_wine verify_key_nonexist(hkey, "Subkey2");
todo_wine ok(err == ERROR_FILE_NOT_FOUND, "got %d, expected 2\n", err);
test_import_str("REGEDIT4\n\n" test_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n" "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
...@@ -2441,15 +2432,13 @@ static void test_unicode_import(void) ...@@ -2441,15 +2432,13 @@ static void test_unicode_import(void)
"[HKEY_CURRENT_USER\\" KEY_BASE "\\\n" "[HKEY_CURRENT_USER\\" KEY_BASE "\\\n"
"Subkey1]\n", &r); "Subkey1]\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
err = RegOpenKeyExA(hkey, "Subkey1", 0, KEY_READ, &subkey); todo_wine verify_key_nonexist(hkey, "Subkey1");
todo_wine ok(err == ERROR_FILE_NOT_FOUND, "got %d, expected 2\n", err);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n" test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\n" "[HKEY_CURRENT_USER\\" KEY_BASE "\n"
"\\Subkey2]\n", &r); "\\Subkey2]\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
err = RegOpenKeyExA(hkey, "Subkey2", 0, KEY_READ, &subkey); todo_wine verify_key_nonexist(hkey, "Subkey2");
todo_wine ok(err == ERROR_FILE_NOT_FOUND, "got %d, expected 2\n", err);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n" test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n" "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment