Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
6cc4510b
Commit
6cc4510b
authored
Jan 16, 2007
by
James Hawkins
Committed by
Alexandre Julliard
Jan 16, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Add tests for RegQueryValue.
parent
c8eb8076
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
0 deletions
+117
-0
registry.c
dlls/advapi32/tests/registry.c
+117
-0
No files found.
dlls/advapi32/tests/registry.c
View file @
6cc4510b
...
...
@@ -746,6 +746,122 @@ static void test_regconnectregistry( void)
}
static
void
test_reg_query_value
(
void
)
{
HKEY
subkey
;
CHAR
val
[
MAX_PATH
];
WCHAR
valW
[
5
];
LONG
size
,
ret
;
static
const
WCHAR
expected
[]
=
{
'd'
,
'a'
,
't'
,
'a'
,
0
};
static
const
WCHAR
set
[]
=
{
'd'
,
'a'
,
't'
,
'a'
};
ret
=
RegCreateKeyA
(
hkey_main
,
"subkey"
,
&
subkey
);
ok
(
ret
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
ret
);
ret
=
RegSetValueA
(
subkey
,
NULL
,
REG_SZ
,
"data"
,
4
);
ok
(
ret
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
ret
);
/* try an invalid hkey */
SetLastError
(
0xdeadbeef
);
size
=
MAX_PATH
;
ret
=
RegQueryValueA
((
HKEY
)
0xcafebabe
,
"subkey"
,
val
,
&
size
);
ok
(
ret
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %d
\n
"
,
GetLastError
());
/* try a NULL hkey */
SetLastError
(
0xdeadbeef
);
size
=
MAX_PATH
;
ret
=
RegQueryValueA
(
NULL
,
"subkey"
,
val
,
&
size
);
ok
(
ret
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %d
\n
"
,
GetLastError
());
/* try a NULL value */
size
=
MAX_PATH
;
ret
=
RegQueryValueA
(
hkey_main
,
"subkey"
,
NULL
,
&
size
);
ok
(
ret
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
ret
);
ok
(
size
==
5
,
"Expected 5, got %d
\n
"
,
size
);
/* try a NULL size */
SetLastError
(
0xdeadbeef
);
val
[
0
]
=
'\0'
;
ret
=
RegQueryValueA
(
hkey_main
,
"subkey"
,
val
,
NULL
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %d
\n
"
,
GetLastError
());
ok
(
lstrlenA
(
val
)
==
0
,
"Expected val to be untouched, got %s
\n
"
,
val
);
/* try a NULL value and size */
ret
=
RegQueryValueA
(
hkey_main
,
"subkey"
,
NULL
,
NULL
);
ok
(
ret
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
ret
);
/* try a size too small */
SetLastError
(
0xdeadbeef
);
val
[
0
]
=
'\0'
;
size
=
1
;
ret
=
RegQueryValueA
(
hkey_main
,
"subkey"
,
val
,
&
size
);
ok
(
ret
==
ERROR_MORE_DATA
,
"Expected ERROR_MORE_DATA, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %d
\n
"
,
GetLastError
());
ok
(
lstrlenA
(
val
)
==
0
,
"Expected val to be untouched, got %s
\n
"
,
val
);
ok
(
size
==
5
,
"Expected 5, got %d
\n
"
,
size
);
/* successfully read the value using 'subkey' */
size
=
MAX_PATH
;
ret
=
RegQueryValueA
(
hkey_main
,
"subkey"
,
val
,
&
size
);
ok
(
ret
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
ret
);
ok
(
!
lstrcmpA
(
val
,
"data"
),
"Expected 'data', got '%s'
\n
"
,
val
);
ok
(
size
==
5
,
"Expected 5, got %d
\n
"
,
size
);
/* successfully read the value using the subkey key */
size
=
MAX_PATH
;
ret
=
RegQueryValueA
(
subkey
,
NULL
,
val
,
&
size
);
ok
(
ret
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
ret
);
ok
(
!
lstrcmpA
(
val
,
"data"
),
"Expected 'data', got '%s'
\n
"
,
val
);
ok
(
size
==
5
,
"Expected 5, got %d
\n
"
,
size
);
/* unicode - try size too small */
SetLastError
(
0xdeadbeef
);
valW
[
0
]
=
'\0'
;
size
=
0
;
ret
=
RegQueryValueW
(
subkey
,
NULL
,
valW
,
&
size
);
ok
(
ret
==
ERROR_MORE_DATA
,
"Expected ERROR_MORE_DATA, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %d
\n
"
,
GetLastError
());
ok
(
lstrlenW
(
valW
)
==
0
,
"Expected valW to be untouched
\n
"
);
ok
(
size
==
sizeof
(
expected
),
"Got wrong size: %d
\n
"
,
size
);
/* unicode - try size in WCHARS */
SetLastError
(
0xdeadbeef
);
size
=
sizeof
(
valW
)
/
sizeof
(
WCHAR
);
ret
=
RegQueryValueW
(
subkey
,
NULL
,
valW
,
&
size
);
ok
(
ret
==
ERROR_MORE_DATA
,
"Expected ERROR_MORE_DATA, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %d
\n
"
,
GetLastError
());
ok
(
lstrlenW
(
valW
)
==
0
,
"Expected valW to be untouched
\n
"
);
ok
(
size
==
sizeof
(
expected
),
"Got wrong size: %d
\n
"
,
size
);
/* unicode - successfully read the value */
size
=
sizeof
(
valW
);
ret
=
RegQueryValueW
(
subkey
,
NULL
,
valW
,
&
size
);
ok
(
ret
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
ret
);
ok
(
!
lstrcmpW
(
valW
,
expected
),
"Got wrong value
\n
"
);
ok
(
size
==
sizeof
(
expected
),
"Got wrong size: %d
\n
"
,
size
);
/* unicode - set the value without a NULL terminator */
ret
=
RegSetValueW
(
subkey
,
NULL
,
REG_SZ
,
set
,
sizeof
(
set
));
ok
(
ret
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
ret
);
/* unicode - read the unterminated value, value is terminated for us */
memset
(
valW
,
'a'
,
sizeof
(
valW
));
size
=
sizeof
(
valW
);
ret
=
RegQueryValueW
(
subkey
,
NULL
,
valW
,
&
size
);
todo_wine
{
ok
(
ret
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
ret
);
ok
(
!
lstrcmpW
(
valW
,
expected
),
"Got wrong value
\n
"
);
ok
(
size
==
sizeof
(
expected
),
"Got wrong size: %d
\n
"
,
size
);
}
RegDeleteKeyA
(
subkey
,
""
);
}
START_TEST
(
registry
)
{
setup_main_key
();
...
...
@@ -758,6 +874,7 @@ START_TEST(registry)
test_reg_create_key
();
test_reg_close_key
();
test_reg_delete_key
();
test_reg_query_value
();
/* SaveKey/LoadKey require the SE_BACKUP_NAME privilege to be set */
if
(
set_privileges
(
SE_BACKUP_NAME
,
TRUE
)
&&
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment