Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/tests/add.c | 13 +++++++++---- programs/reg/tests/delete.c | 8 +++----- programs/reg/tests/export.c | 9 +++------ 3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c index 8357e9ad0bc..e62caeade01 100644 --- a/programs/reg/tests/add.c +++ b/programs/reg/tests/add.c @@ -126,10 +126,16 @@ void verify_key_nonexist_(const char *file, unsigned line, HKEY key_base, const void add_key_(const char *file, unsigned line, const HKEY hkey, const char *path, HKEY *subkey) { LONG err; + HKEY new_key;
err = RegCreateKeyExA(hkey, path, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_READ|KEY_WRITE, NULL, subkey, NULL); + KEY_READ|KEY_WRITE, NULL, &new_key, NULL); lok(err == ERROR_SUCCESS, "RegCreateKeyExA failed: %d\n", err); + + if (subkey) + *subkey = new_key; + else + RegCloseKey(new_key); }
void delete_key_(const char *file, unsigned line, const HKEY hkey, const char *path) @@ -315,7 +321,7 @@ static void test_key_formats(void)
static void test_add(void) { - HKEY hkey, hsubkey; + HKEY hkey; DWORD r, dword;
run_reg_exe("reg add HKCU\" KEY_BASE " /f", &r); @@ -324,8 +330,7 @@ static void test_add(void) open_key(HKEY_CURRENT_USER, KEY_BASE, KEY_WRITE, &hkey);
/* Test whether overwriting a registry key modifies existing keys and values */ - add_key(hkey, "Subkey", &hsubkey); - close_key(hsubkey); + add_key(hkey, "Subkey", NULL); add_value(hkey, "Test1", REG_SZ, "Value1", 7); dword = 0x123; add_value(hkey, "Test2", REG_DWORD, &dword, sizeof(dword)); diff --git a/programs/reg/tests/delete.c b/programs/reg/tests/delete.c index 77d95d013c9..575c393d2b3 100644 --- a/programs/reg/tests/delete.c +++ b/programs/reg/tests/delete.c @@ -21,7 +21,7 @@
static void test_delete(void) { - HKEY hkey, hsubkey; + HKEY hkey; DWORD r; const DWORD deadbeef = 0xdeadbeef;
@@ -75,8 +75,7 @@ static void test_delete(void) add_value(hkey, "bar", REG_DWORD, &deadbeef, sizeof(deadbeef)); add_value(hkey, NULL, REG_DWORD, &deadbeef, sizeof(deadbeef));
- add_key(hkey, "subkey", &hsubkey); - close_key(hsubkey); + add_key(hkey, "subkey", NULL);
run_reg_exe("reg delete HKCU\" KEY_BASE " /v bar /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -92,8 +91,7 @@ static void test_delete(void) verify_key(hkey, "subkey");
/* Test forward and back slashes */ - add_key(hkey, "https://winehq.org", &hsubkey); - close_key(hsubkey); + add_key(hkey, "https://winehq.org", NULL); add_value(hkey, "count/up", REG_SZ, "one/two/three", 14); add_value(hkey, "\foo\bar", REG_SZ, "", 1);
diff --git a/programs/reg/tests/export.c b/programs/reg/tests/export.c index 4e5ac4c71d9..daf42f66e3e 100644 --- a/programs/reg/tests/export.c +++ b/programs/reg/tests/export.c @@ -291,10 +291,8 @@ static void test_export(void)
/* Test the export order of registry keys */ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); - add_key(hkey, "Subkey2", &subkey); - close_key(subkey); - add_key(hkey, "Subkey1", &subkey); - close_key(subkey); + add_key(hkey, "Subkey2", NULL); + add_key(hkey, "Subkey1", NULL);
run_reg_exe("reg export HKEY_CURRENT_USER\" KEY_BASE " file.reg /y", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -405,8 +403,7 @@ static void test_export(void)
/* Test registry export with forward and back slashes */ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); - add_key(hkey, "https://winehq.org", &subkey); - close_key(subkey); + add_key(hkey, "https://winehq.org", NULL); add_value(hkey, "count/up", REG_SZ, "one/two/three", 14); add_value(hkey, "\foo\bar", REG_SZ, "", 1); close_key(hkey);
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/tests/add.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c index e62caeade01..36b5f821350 100644 --- a/programs/reg/tests/add.c +++ b/programs/reg/tests/add.c @@ -329,6 +329,46 @@ static void test_add(void)
open_key(HKEY_CURRENT_USER, KEY_BASE, KEY_WRITE, &hkey);
+ /* The Default value is initialized if no parameters are specified */ + todo_wine verify_reg(hkey, NULL, REG_SZ, "", 1, 0); + todo_wine delete_value(hkey, NULL); + + /* This also occurs when specifying a registry type and passing data */ + run_reg_exe("reg add HKCU\" KEY_BASE " /t REG_DWORD /d 0x5 /f", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + dword = 0x5; + verify_reg(hkey, NULL, REG_DWORD, &dword, sizeof(dword), 0); + + /* The Default value can also be overwritten as an empty string */ + run_reg_exe("reg add HKCU\" KEY_BASE " /f", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + verify_reg(hkey, NULL, REG_SZ, "", 1, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA); + + close_key(hkey); + delete_key(HKEY_CURRENT_USER, KEY_BASE); + + /* Specifying a value name doesn't initialize the Default value in a new key */ + run_reg_exe("reg add HKCU\" KEY_BASE " /v Test /t REG_SZ /d "Just me here" /f", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + + open_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); + + verify_reg(hkey, "Test", REG_SZ, "Just me here", 13, 0); + verify_reg_nonexist(hkey, NULL); + + close_key(hkey); + delete_key(HKEY_CURRENT_USER, KEY_BASE); + + /* Adding a registry key via WinAPI doesn't initialize the Default value... */ + add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + verify_reg_nonexist(hkey, NULL); + + /* ... but we can add it without passing [/f] to reg.exe */ + run_reg_exe("reg add HKCU\" KEY_BASE, &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + todo_wine verify_reg(hkey, NULL, REG_SZ, "", 1, 0); + todo_wine delete_value(hkey, NULL); + /* Test whether overwriting a registry key modifies existing keys and values */ add_key(hkey, "Subkey", NULL); add_value(hkey, "Test1", REG_SZ, "Value1", 7); @@ -342,6 +382,7 @@ static void test_add(void) verify_key(hkey, "Subkey"); verify_reg(hkey, "Test1", REG_SZ, "Value1", 7, 0); verify_reg(hkey, "Test2", REG_DWORD, &dword, sizeof(dword), 0); + todo_wine verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
close_key(hkey); delete_tree(HKEY_CURRENT_USER, KEY_BASE);