Index: apitests/advapi32/CMakeLists.txt =================================================================== --- modules/rostests/apitests/advapi32/CMakeLists.txt (revision 72193) +++ modules/rostests/apitests/advapi32/CMakeLists.txt (working copy) @@ -6,6 +6,7 @@ IsTextUnicode.c LockDatabase.c QueryServiceConfig2.c + RegEnumKey.c RegEnumValueW.c RegQueryInfoKey.c RtlEncryptMemory.c Index: apitests/advapi32/RegEnumKey.c =================================================================== --- modules/rostests/apitests/advapi32/RegEnumKey.c (nonexistent) +++ modules/rostests/apitests/advapi32/RegEnumKey.c (working copy) @@ -0,0 +1,177 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for the RegEnumKey API + * PROGRAMMER: Thomas Faber & Doug Lyons + */ + +#include + +#define WIN32_NO_STATUS +#include + +START_TEST(RegEnumKey) +{ + LONG ErrorCode; + HKEY TestKey; + HKEY hKey; + WCHAR nameBuf2[2] = { '\0', '\0' }; /* Set chars initially to zeros */ + WCHAR nameBuf3[3] = { '\0', '\0', '\0' }; /* Set chars initially to zeros */ + DWORD nameLen = 1; + + /* Create our one character Test Key */ + ErrorCode = RegCreateKeyW( HKEY_CURRENT_USER, L"Software\\ReactOS_apitest\\1", &TestKey ); + ok_dec(ErrorCode, ERROR_SUCCESS); + + /* Enumerate first key reading only 1 char plus zero terminator */ + RegOpenKeyExW(HKEY_CURRENT_USER, + L"Software\\ReactOS_apitest", + 0, KEY_READ, &hKey); + ErrorCode = (RegEnumKeyExW(hKey, 0, nameBuf2, &nameLen, NULL, NULL, NULL, NULL)); + ok_dec(ErrorCode, ERROR_MORE_DATA); + ok(nameBuf2[0] == 0, "nameBuf2[0] = %d, expected 0\n", nameBuf2[0]); + ok(nameBuf2[1] == 0, "nameBuf2[1] = %d, expected 0\n", nameBuf2[1]); + ok(nameLen == 1, "nameLen = %ld, expected 1\n", nameLen); + ok(wcslen(nameBuf2) == 0, "len of nameBuf2 = %d, expected 0\n", wcslen(nameBuf2)); + + /* Delete the key */ + ErrorCode = RegDeleteKeyW(TestKey, L""); + ok_dec(ErrorCode, ERROR_SUCCESS); + RegCloseKey(TestKey); + + + /* Reset initial parameters */ + nameBuf2[0] = 0; + nameBuf2[1] = 0; + nameLen = 2; + + /* Create our one character Test Key */ + ErrorCode = RegCreateKeyW( HKEY_CURRENT_USER, L"Software\\ReactOS_apitest\\1", &TestKey ); + ok_dec(ErrorCode, ERROR_SUCCESS); + + /* Enumerate first key reading only 1 char plus zero terminator */ + RegOpenKeyExW(HKEY_CURRENT_USER, + L"Software\\ReactOS_apitest", + 0, KEY_READ, &hKey); + ErrorCode = (RegEnumKeyExW(hKey, 0, nameBuf2, &nameLen, NULL, NULL, NULL, NULL)); + ok_dec(ErrorCode, ERROR_SUCCESS); + ok(nameBuf2[0] == '1', "nameBuf2[0] = %d, expected 49\n", nameBuf2[0]); + ok(nameBuf2[1] == 0, "nameBuf2[1] = %d, expected 0\n", nameBuf2[1]); + ok(nameLen == 1, "nameLen = %ld, expected 1\n", nameLen); + ok(wcslen(nameBuf2) == 1, "len of nameBuf2 = %d, expected 1\n", wcslen(nameBuf2)); + + + /* Delete the key */ + ErrorCode = RegDeleteKeyW(TestKey, L""); + ok_dec(ErrorCode, ERROR_SUCCESS); + RegCloseKey(TestKey); + + /* Reset initial parameters */ + nameBuf2[0] = 0; + nameBuf2[1] = 0; + nameLen = 2; + + /* Create our two character Test Key */ + ErrorCode = RegCreateKeyW( HKEY_CURRENT_USER, L"Software\\ReactOS_apitest\\12", &TestKey ); + ok_dec(ErrorCode, ERROR_SUCCESS); + + /* Enumerate first key reading only 1 char plus zero terminator */ + RegOpenKeyExW(HKEY_CURRENT_USER, + L"Software\\ReactOS_apitest", + 0, KEY_READ, &hKey); + ErrorCode = (RegEnumKeyExW(hKey, 0, nameBuf2, &nameLen, NULL, NULL, NULL, NULL)); + ok_dec(ErrorCode, ERROR_MORE_DATA); + ok(nameBuf2[0] == 0, "nameBuf2[0] = %d, expected 0\n", nameBuf2[0]); + ok(nameBuf2[1] == 0, "nameBuf2[1] = %d, expected 0\n", nameBuf2[1]); + ok(nameLen == 2, "nameLen = %ld, expected 2\n", nameLen); + ok(wcslen(nameBuf2) == 0, "len of nameBuf2 = %d, expected 0\n", wcslen(nameBuf2)); + + /* Delete the key */ + ErrorCode = RegDeleteKeyW(TestKey, L""); + ok_dec(ErrorCode, ERROR_SUCCESS); + RegCloseKey(TestKey); + + /* Reset initial parameters */ + nameBuf2[0] = 0; + nameBuf2[1] = 0; + nameLen = 3; /* Set Buffer Length too long, but buffer long enough to fit w/o \0 */ + + /* Create our two character Test Key */ + ErrorCode = RegCreateKeyW( HKEY_CURRENT_USER, L"Software\\ReactOS_apitest\\12", &TestKey ); + ok_dec(ErrorCode, ERROR_SUCCESS); + + /* Enumerate first key reading only 1 char plus zero terminator */ + RegOpenKeyExW(HKEY_CURRENT_USER, + L"Software\\ReactOS_apitest", + 0, KEY_READ, &hKey); + ErrorCode = (RegEnumKeyExW(hKey, 0, nameBuf2, &nameLen, NULL, NULL, NULL, NULL)); + ok_dec(ErrorCode, ERROR_SUCCESS); + ok(nameBuf2[0] == '1', "nameBuf2[0] = %d, expected 49\n", nameBuf2[0]); + ok(nameBuf2[1] == '2', "nameBuf2[1] = %d, expected 50\n", nameBuf2[1]); + + /* nameLen should be changed to 2 to match actual key length */ + ok(nameLen == 2, "nameLen = %ld, expected 2\n", nameLen); + ok(wcslen(nameBuf2) == 2, "len of nameBuf2 = %d, expected 2\n", wcslen(nameBuf2)); + + /* Delete the key */ + ErrorCode = RegDeleteKeyW(TestKey, L""); + ok_dec(ErrorCode, ERROR_SUCCESS); + RegCloseKey(TestKey); + + /* Set initial parameters */ + nameBuf3[0] = 0; + nameBuf3[1] = 0; + nameBuf3[2] = 0; + nameLen = 3; /* Set Buffer Length too long, but buffer long enough without \0 */ + + /* Create our two character Test Key */ + ErrorCode = RegCreateKeyW( HKEY_CURRENT_USER, L"Software\\ReactOS_apitest\\123", &TestKey ); + ok_dec(ErrorCode, ERROR_SUCCESS); + + /* Enumerate first key reading only 1 char plus zero terminator */ + RegOpenKeyExW(HKEY_CURRENT_USER, + L"Software\\ReactOS_apitest", + 0, KEY_READ, &hKey); + ErrorCode = (RegEnumKeyExW(hKey, 0, nameBuf3, &nameLen, NULL, NULL, NULL, NULL)); + ok_dec(ErrorCode, ERROR_MORE_DATA); + ok(nameBuf3[0] == 0, "nameBuf3[0] = %d, expected 0\n", nameBuf3[0]); + ok(nameBuf3[1] == 0, "nameBuf3[1] = %d, expected 0\n", nameBuf3[1]); + ok(nameBuf3[2] == 0, "nameBuf3[2] = %d, expected 0\n", nameBuf3[2]); + + ok(nameLen == 3, "nameLen = %ld, expected 3\n", nameLen); + ok(wcslen(nameBuf3) == 0, "len of nameBuf3 = %d, expected 0\n", wcslen(nameBuf3)); + + /* Delete the key */ + ErrorCode = RegDeleteKeyW(TestKey, L""); + ok_dec(ErrorCode, ERROR_SUCCESS); + RegCloseKey(TestKey); + + /* Set initial parameters */ + nameBuf3[0] = 0; + nameBuf3[1] = 0; + nameBuf3[2] = 0; + nameLen = 4; /* Set Buffer Length too long, but buffer long enough without \0 */ + + /* Create our two character Test Key */ + ErrorCode = RegCreateKeyW( HKEY_CURRENT_USER, L"Software\\ReactOS_apitest\\123", &TestKey ); + ok_dec(ErrorCode, ERROR_SUCCESS); + + /* Enumerate first key reading only 1 char plus zero terminator */ + RegOpenKeyExW(HKEY_CURRENT_USER, + L"Software\\ReactOS_apitest", + 0, KEY_READ, &hKey); + ErrorCode = (RegEnumKeyExW(hKey, 0, nameBuf3, &nameLen, NULL, NULL, NULL, NULL)); + ok_dec(ErrorCode, ERROR_SUCCESS); + ok(nameBuf3[0] == '1', "nameBuf3[0] = %d, expected 49\n", nameBuf3[0]); + ok(nameBuf3[1] == '2', "nameBuf3[1] = %d, expected 50\n", nameBuf3[1]); + ok(nameBuf3[2] == '3', "nameBuf3[2] = %d, expected 51\n", nameBuf3[2]); + + ok(nameLen == 3, "nameLen = %ld, expected 3\n", nameLen); + ok(wcslen(nameBuf3) == 3, "len of nameBuf3 = %d, expected 3\n", wcslen(nameBuf3)); + + /* Delete the key */ + ErrorCode = RegDeleteKeyW(TestKey, L""); + ok_dec(ErrorCode, ERROR_SUCCESS); + RegCloseKey(TestKey); +} + Index: apitests/advapi32/testlist.c =================================================================== --- modules/rostests/apitests/advapi32/testlist.c (revision 72193) +++ modules/rostests/apitests/advapi32/testlist.c (working copy) @@ -9,6 +9,7 @@ extern void func_IsTextUnicode(void); extern void func_LockDatabase(void); extern void func_QueryServiceConfig2(void); +extern void func_RegEnumKey(void); extern void func_RegEnumValueW(void); extern void func_RegQueryInfoKey(void); extern void func_RtlEncryptMemory(void); @@ -22,6 +23,7 @@ { "IsTextUnicode" , func_IsTextUnicode }, { "LockDatabase" , func_LockDatabase }, { "QueryServiceConfig2", func_QueryServiceConfig2 }, + { "RegEnumKey", func_RegEnumKey }, { "RegEnumValueW", func_RegEnumValueW }, { "RegQueryInfoKey", func_RegQueryInfoKey }, { "RtlEncryptMemory", func_RtlEncryptMemory },