mirror of
https://github.com/reactos/reactos.git
synced 2025-01-06 06:20:13 +00:00
[ADVAPI32_APITEST]
- Add a test for RegEnumKeyExW showing that it should return ERROR_MORE_DATA instead of ERROR_BUFFER_OVERFLOW when the name buffer is too small. Based on a patch by Doug Lyons. CORE-12030 svn path=/trunk/; revision=72876
This commit is contained in:
parent
254a9ba114
commit
3a5e3ae774
3 changed files with 89 additions and 0 deletions
|
@ -7,6 +7,7 @@ list(APPEND SOURCE
|
||||||
IsTextUnicode.c
|
IsTextUnicode.c
|
||||||
LockDatabase.c
|
LockDatabase.c
|
||||||
QueryServiceConfig2.c
|
QueryServiceConfig2.c
|
||||||
|
RegEnumKey.c
|
||||||
RegEnumValueW.c
|
RegEnumValueW.c
|
||||||
RegQueryInfoKey.c
|
RegQueryInfoKey.c
|
||||||
RtlEncryptMemory.c
|
RtlEncryptMemory.c
|
||||||
|
|
86
rostests/apitests/advapi32/RegEnumKey.c
Normal file
86
rostests/apitests/advapi32/RegEnumKey.c
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* 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 <apitest.h>
|
||||||
|
|
||||||
|
#define WIN32_NO_STATUS
|
||||||
|
#include <winreg.h>
|
||||||
|
|
||||||
|
START_TEST(RegEnumKey)
|
||||||
|
{
|
||||||
|
LONG ErrorCode;
|
||||||
|
HKEY TestKey;
|
||||||
|
HKEY hKey;
|
||||||
|
WCHAR nameBuf[4];
|
||||||
|
DWORD nameLen;
|
||||||
|
|
||||||
|
/* Base key for our test */
|
||||||
|
ErrorCode = RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS_apitest", 0, NULL, 0, KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS, NULL, &hKey, NULL);
|
||||||
|
ok_dec(ErrorCode, ERROR_SUCCESS);
|
||||||
|
|
||||||
|
/* Create 1 char subkey */
|
||||||
|
ErrorCode = RegCreateKeyExW(hKey, L"1", 0, NULL, 0, READ_CONTROL, NULL, &TestKey, NULL);
|
||||||
|
ok_dec(ErrorCode, ERROR_SUCCESS);
|
||||||
|
RegCloseKey(TestKey);
|
||||||
|
|
||||||
|
/* Enumerate first key with space for 1 char */
|
||||||
|
nameLen = 1;
|
||||||
|
FillMemory(nameBuf, sizeof(nameBuf), 0x55);
|
||||||
|
ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
|
||||||
|
ok_dec(ErrorCode, ERROR_MORE_DATA);
|
||||||
|
ok_hex(nameBuf[0], 0x5555);
|
||||||
|
ok_hex(nameBuf[1], 0x5555);
|
||||||
|
ok_dec(nameLen, 1);
|
||||||
|
|
||||||
|
/* Enumerate first key with space for 2 chars */
|
||||||
|
nameLen = 2;
|
||||||
|
FillMemory(nameBuf, sizeof(nameBuf), 0x55);
|
||||||
|
ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
|
||||||
|
ok_dec(ErrorCode, ERROR_SUCCESS);
|
||||||
|
ok_hex(nameBuf[0], L'1');
|
||||||
|
ok_hex(nameBuf[1], 0);
|
||||||
|
ok_hex(nameBuf[2], 0x5555);
|
||||||
|
ok_dec(nameLen, 1);
|
||||||
|
|
||||||
|
/* Delete the subkey */
|
||||||
|
ErrorCode = RegDeleteKeyW(hKey, L"1");
|
||||||
|
ok_dec(ErrorCode, ERROR_SUCCESS);
|
||||||
|
|
||||||
|
/* Create 2 char subkey */
|
||||||
|
ErrorCode = RegCreateKeyExW(hKey, L"12", 0, NULL, 0, READ_CONTROL, NULL, &TestKey, NULL);
|
||||||
|
ok_dec(ErrorCode, ERROR_SUCCESS);
|
||||||
|
RegCloseKey(TestKey);
|
||||||
|
|
||||||
|
/* Enumerate first key with space for 2 chars */
|
||||||
|
FillMemory(nameBuf, sizeof(nameBuf), 0x55);
|
||||||
|
nameLen = 2;
|
||||||
|
ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
|
||||||
|
ok_dec(ErrorCode, ERROR_MORE_DATA);
|
||||||
|
ok_hex(nameBuf[0], 0x5555);
|
||||||
|
ok_hex(nameBuf[1], 0x5555);
|
||||||
|
ok(nameLen == 2, "nameLen = %ld, expected 2\n", nameLen);
|
||||||
|
|
||||||
|
/* Enumerate first key with space for 3 chars */
|
||||||
|
FillMemory(nameBuf, sizeof(nameBuf), 0x55);
|
||||||
|
nameLen = 3;
|
||||||
|
ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
|
||||||
|
ok_dec(ErrorCode, ERROR_SUCCESS);
|
||||||
|
ok_hex(nameBuf[0], L'1');
|
||||||
|
ok_hex(nameBuf[1], L'2');
|
||||||
|
ok_hex(nameBuf[2], 0);
|
||||||
|
ok_hex(nameBuf[3], 0x5555);
|
||||||
|
ok(nameLen == 2, "nameLen = %ld, expected 2\n", nameLen);
|
||||||
|
|
||||||
|
/* Delete the subkey */
|
||||||
|
ErrorCode = RegDeleteKeyW(hKey, L"12");
|
||||||
|
ok_dec(ErrorCode, ERROR_SUCCESS);
|
||||||
|
|
||||||
|
/* Delete our parent key */
|
||||||
|
ErrorCode = RegDeleteKeyW(hKey, L"");
|
||||||
|
ok_dec(ErrorCode, ERROR_SUCCESS);
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ extern void func_HKEY_CLASSES_ROOT(void);
|
||||||
extern void func_IsTextUnicode(void);
|
extern void func_IsTextUnicode(void);
|
||||||
extern void func_LockDatabase(void);
|
extern void func_LockDatabase(void);
|
||||||
extern void func_QueryServiceConfig2(void);
|
extern void func_QueryServiceConfig2(void);
|
||||||
|
extern void func_RegEnumKey(void);
|
||||||
extern void func_RegEnumValueW(void);
|
extern void func_RegEnumValueW(void);
|
||||||
extern void func_RegQueryInfoKey(void);
|
extern void func_RegQueryInfoKey(void);
|
||||||
extern void func_RtlEncryptMemory(void);
|
extern void func_RtlEncryptMemory(void);
|
||||||
|
@ -24,6 +25,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "IsTextUnicode" , func_IsTextUnicode },
|
{ "IsTextUnicode" , func_IsTextUnicode },
|
||||||
{ "LockDatabase" , func_LockDatabase },
|
{ "LockDatabase" , func_LockDatabase },
|
||||||
{ "QueryServiceConfig2", func_QueryServiceConfig2 },
|
{ "QueryServiceConfig2", func_QueryServiceConfig2 },
|
||||||
|
{ "RegEnumKey", func_RegEnumKey },
|
||||||
{ "RegEnumValueW", func_RegEnumValueW },
|
{ "RegEnumValueW", func_RegEnumValueW },
|
||||||
{ "RegQueryInfoKey", func_RegQueryInfoKey },
|
{ "RegQueryInfoKey", func_RegQueryInfoKey },
|
||||||
{ "RtlEncryptMemory", func_RtlEncryptMemory },
|
{ "RtlEncryptMemory", func_RtlEncryptMemory },
|
||||||
|
|
Loading…
Reference in a new issue