-- v2: atl: Convert REG_DWORD to a correct type. atl/tests: Move regular DWORD tests into a loop.
From: Jactry Zeng jzeng@codeweavers.com
--- dlls/atl/tests/registrar.c | 42 +++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/dlls/atl/tests/registrar.c b/dlls/atl/tests/registrar.c index ab31f9532b1..f6b9d422cb5 100644 --- a/dlls/atl/tests/registrar.c +++ b/dlls/atl/tests/registrar.c @@ -59,7 +59,20 @@ static void test_registrar(void) IRegistrar *registrar = NULL; HRESULT hr; INT count; + int i; WCHAR *textW = NULL; + struct dword_test + { + const char *name; + BOOL preserved; + LONGLONG value; + } dword_tests[] = + { + { "dword_unquoted_dec", TRUE, 1 }, + { "dword_quoted_dec", TRUE, 1 }, + { "dword_quoted_hex", FALSE, 0xA }, + { "dword_unquoted_hex", FALSE, 0xA }, + };
if (!GetProcAddress(GetModuleHandleA("atl.dll"), "AtlAxAttachControl")) { @@ -112,25 +125,16 @@ static void test_registrar(void) ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %ld\n", lret); ok(!strcmp( buffer, "str'ing"), "wrong data %s\n", debugstr_a(buffer));
- size = sizeof(dword); - lret = RegQueryValueExA(key, "dword_unquoted_hex", NULL, NULL, (BYTE*)&dword, &size); - ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %ld\n", lret); - ok(dword != 0xA, "unquoted hex is not supposed to be preserved\n"); - - size = sizeof(dword); - lret = RegQueryValueExA(key, "dword_quoted_hex", NULL, NULL, (BYTE*)&dword, &size); - ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %ld\n", lret); - ok(dword != 0xA, "quoted hex is not supposed to be preserved\n"); - - size = sizeof(dword); - lret = RegQueryValueExA(key, "dword_unquoted_dec", NULL, NULL, (BYTE*)&dword, &size); - ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %ld\n", lret); - ok(dword == 1, "unquoted dec is not supposed to be %ld\n", dword); - - size = sizeof(dword); - lret = RegQueryValueExA(key, "dword_quoted_dec", NULL, NULL, (BYTE*)&dword, &size); - ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %ld\n", lret); - ok(dword == 1, "quoted dec is not supposed to be %ld\n", dword); + for (i = 0; i < ARRAYSIZE(dword_tests); i++) + { + size = sizeof(dword); + lret = RegQueryValueExA(key, dword_tests[i].name, NULL, NULL, (BYTE*)&dword, &size); + ok(lret == ERROR_SUCCESS, "Test %d: RegQueryValueExA failed %ld.\n", i, lret); + if (dword_tests[i].preserved) + ok(dword == dword_tests[i].value, "Test %d: got unexpected value %lu.\n", i, dword); + else + ok(dword != dword_tests[i].value, "Test %d: is not supposed to be preserved.\n", i); + }
size = 4; lret = RegQueryValueExA(key, "binary_quoted", NULL, NULL, bytes, &size);
From: Jactry Zeng jzeng@codeweavers.com
--- dlls/atl/registrar.c | 2 +- dlls/atl/tests/registrar.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/atl/registrar.c b/dlls/atl/registrar.c index 9009cd1c7cf..59023944147 100644 --- a/dlls/atl/registrar.c +++ b/dlls/atl/registrar.c @@ -280,7 +280,7 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO hres = get_word(&iter, buf); if(FAILED(hres)) break; - dw = wcstol(buf->str, NULL, 10); + dw = wcstoul(buf->str, NULL, 10); lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_DWORD, (PBYTE)&dw, sizeof(dw)); if(lres != ERROR_SUCCESS) { diff --git a/dlls/atl/tests/registrar.c b/dlls/atl/tests/registrar.c index f6b9d422cb5..38e6dc9d3f9 100644 --- a/dlls/atl/tests/registrar.c +++ b/dlls/atl/tests/registrar.c @@ -49,6 +49,10 @@ static const char textA[] = " val 'dword_unquoted_dec' = d 1 \n" " val 'dword_quoted_hex' = d '0xA' \n" " val 'dword_unquoted_hex' = d 0xA \n" +" val 'dword_negative' = d -2147483648 \n" +" val 'dword_ulong' = d 2147483649 \n" +" val 'dword_max' = d 4294967295 \n" +" val 'dword_overrange' = d 4294967296 \n" " val 'binary_quoted' = b 'deadbeef' \n" " val 'binary_unquoted' = b dead0123 \n" " } \n" @@ -72,6 +76,10 @@ static void test_registrar(void) { "dword_quoted_dec", TRUE, 1 }, { "dword_quoted_hex", FALSE, 0xA }, { "dword_unquoted_hex", FALSE, 0xA }, + { "dword_negative", FALSE, -2147483648 }, + { "dword_ulong", TRUE, 2147483649 }, + { "dword_max", TRUE, 4294967295 }, + { "dword_overrange", FALSE, 4294967296 }, };
if (!GetProcAddress(GetModuleHandleA("atl.dll"), "AtlAxAttachControl"))