From 1a38b7bf5e561a89c571feab7193ea9b382f9f19 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 15 Jan 2009 05:04:31 +0300 Subject: [PATCH] advapi32/tests: Test for enumeration order preservation of reg keys. --- dlls/advapi32/tests/registry.c | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 6eb9d540297..b63b3e260dd 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -1475,6 +1475,52 @@ static void test_reg_delete_tree(void) "Expected ERROR_FILE_NOT_FOUND, got %d\n", ret); } +static void test_rw_order(void) +{ + HKEY hKey; + DWORD dw = 0; + static char keyname[] = "test_rw_order"; + char value_buf[2]; + DWORD values, value_len, value_name_max_len; + LSTATUS ret; + + RegDeleteKeyA(HKEY_CURRENT_USER, keyname); + ret = RegCreateKeyA(HKEY_CURRENT_USER, keyname, &hKey); + if(ret != ERROR_SUCCESS) { + skip("Couldn't create key. Skipping.\n"); + return; + } + + ok(!RegSetValueExA(hKey, "A", 0, REG_DWORD, (LPBYTE)&dw, sizeof(dw)), + "RegSetValueExA for value \"A\" failed\n"); + ok(!RegSetValueExA(hKey, "C", 0, REG_DWORD, (LPBYTE)&dw, sizeof(dw)), + "RegSetValueExA for value \"C\" failed\n"); + ok(!RegSetValueExA(hKey, "D", 0, REG_DWORD, (LPBYTE)&dw, sizeof(dw)), + "RegSetValueExA for value \"D\" failed\n"); + ok(!RegSetValueExA(hKey, "B", 0, REG_DWORD, (LPBYTE)&dw, sizeof(dw)), + "RegSetValueExA for value \"B\" failed\n"); + + ok(!RegQueryInfoKeyA(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &values, + &value_name_max_len, NULL, NULL, NULL), "RegQueryInfoKeyA failed\n"); + ok(values == 4, "Expected 4 values, got %u\n", values); + + /* Value enumeration preserves RegSetValueEx call order */ + value_len = 2; + ok(!RegEnumValueA(hKey, 0, value_buf, &value_len, NULL, NULL, NULL, NULL), "RegEnumValueA failed\n"); + ok(strcmp(value_buf, "A") == 0, "Expected name \"A\", got %s\n", value_buf); + value_len = 2; + ok(!RegEnumValueA(hKey, 1, value_buf, &value_len, NULL, NULL, NULL, NULL), "RegEnumValueA failed\n"); + todo_wine ok(strcmp(value_buf, "C") == 0, "Expected name \"C\", got %s\n", value_buf); + value_len = 2; + ok(!RegEnumValueA(hKey, 2, value_buf, &value_len, NULL, NULL, NULL, NULL), "RegEnumValueA failed\n"); + todo_wine ok(strcmp(value_buf, "D") == 0, "Expected name \"D\", got %s\n", value_buf); + value_len = 2; + ok(!RegEnumValueA(hKey, 3, value_buf, &value_len, NULL, NULL, NULL, NULL), "RegEnumValueA failed\n"); + todo_wine ok(strcmp(value_buf, "B") == 0, "Expected name \"B\", got %s\n", value_buf); + + ok(!RegDeleteKey(HKEY_CURRENT_USER, keyname), "Failed to delete key\n"); +} + START_TEST(registry) { /* Load pointers for functions that are not available in all Windows versions */ @@ -1506,6 +1552,7 @@ START_TEST(registry) } test_reg_delete_tree(); + test_rw_order(); /* cleanup */ delete_key( hkey_main );