Hugh McMaster : regedit/tests: Test registry export with a simple data structure.

Alexandre Julliard julliard at winehq.org
Mon Sep 25 16:34:31 CDT 2017


Module: wine
Branch: master
Commit: b3032b425e9fa2d4e07be394f535612327d0859e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b3032b425e9fa2d4e07be394f535612327d0859e

Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date:   Mon Sep 25 06:58:21 2017 +0000

regedit/tests: Test registry export with a simple data structure.

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/regedit/tests/regedit.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/programs/regedit/tests/regedit.c b/programs/regedit/tests/regedit.c
index d64a590..4b29183 100644
--- a/programs/regedit/tests/regedit.c
+++ b/programs/regedit/tests/regedit.c
@@ -188,6 +188,16 @@ static void delete_key_(unsigned line, const HKEY hkey, const char *path)
     }
 }
 
+#define add_value(k,n,t,d,s) add_value_(__LINE__,k,n,t,d,s)
+static void add_value_(unsigned line, HKEY hkey, const char *name, DWORD type,
+                       const void *data, size_t size)
+{
+    LONG lr;
+
+    lr = RegSetValueExA(hkey, name, 0, type, (const BYTE *)data, size);
+    lok(lr == ERROR_SUCCESS, "RegSetValueExA failed: %d\n", lr);
+}
+
 #define KEY_BASE "Software\\Wine\\regedit_test"
 
 static void test_basic_import(void)
@@ -3320,11 +3330,18 @@ static void test_export(void)
 {
     LONG lr;
     HKEY hkey;
+    DWORD dword;
 
     const char *empty_key_test =
         "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
         "[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n\r\n";
 
+    const char *simple_test =
+        "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
+        "[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n"
+        "\"DWORD\"=dword:00000100\r\n"
+        "\"String\"=\"Your text here...\"\r\n\r\n";
+
     lr = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
     ok(lr == ERROR_SUCCESS || lr == ERROR_FILE_NOT_FOUND, "RegDeleteKeyA failed: %d\n", lr);
 
@@ -3337,6 +3354,17 @@ static void test_export(void)
     lr = DeleteFileA("file.reg");
     ok(lr, "DeleteFile failed: %u\n", GetLastError());
 
+    /* Test registry export with a simple data structure */
+    dword = 0x100;
+    add_value(hkey, "DWORD", REG_DWORD, &dword, sizeof(dword));
+    add_value(hkey, "String", REG_SZ, "Your text here...", 18);
+
+    run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE);
+    ok(compare_export("file.reg", simple_test), "compare_export() failed\n");
+
+    lr = DeleteFileA("file.reg");
+    ok(lr, "DeleteFile failed: %u\n", GetLastError());
+
     RegCloseKey(hkey);
 
     delete_key(HKEY_CURRENT_USER, KEY_BASE);




More information about the wine-cvs mailing list