Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
a89b9ca1
Commit
a89b9ca1
authored
Aug 25, 2006
by
Frank Richter
Committed by
Alexandre Julliard
Aug 28, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel: Add tests for GetPrivateProfileSectionNames. Make behaviour the same as…
kernel: Add tests for GetPrivateProfileSectionNames. Make behaviour the same as observed on Windows XP.
parent
5c324c81
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
3 deletions
+58
-3
profile.c
dlls/kernel/profile.c
+5
-3
profile.c
dlls/kernel/tests/profile.c
+53
-0
No files found.
dlls/kernel/profile.c
View file @
a89b9ca1
...
...
@@ -906,7 +906,7 @@ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len )
while
((
section
!=
NULL
))
{
if
(
section
->
name
[
0
])
{
tmplen
=
strlenW
(
section
->
name
)
+
1
;
if
(
tmplen
>
buflen
)
{
if
(
tmplen
>
=
buflen
)
{
if
(
buflen
>
0
)
{
memcpy
(
buf
,
section
->
name
,
(
buflen
-
1
)
*
sizeof
(
WCHAR
));
buf
+=
buflen
-
1
;
...
...
@@ -1626,12 +1626,14 @@ DWORD WINAPI GetPrivateProfileSectionNamesA( LPSTR buffer, DWORD size,
retW
=
GetPrivateProfileSectionNamesW
(
bufferW
,
size
,
filenameW
.
Buffer
);
if
(
retW
&&
size
)
{
ret
=
WideCharToMultiByte
(
CP_ACP
,
0
,
bufferW
,
retW
,
buffer
,
size
,
NULL
,
NULL
);
ret
=
WideCharToMultiByte
(
CP_ACP
,
0
,
bufferW
,
retW
+
1
,
buffer
,
size
-
1
,
NULL
,
NULL
);
if
(
!
ret
)
{
ret
=
size
;
ret
=
size
-
2
;
buffer
[
size
-
1
]
=
0
;
}
else
ret
=
ret
-
1
;
}
RtlFreeUnicodeString
(
&
filenameW
);
...
...
dlls/kernel/tests/profile.c
View file @
a89b9ca1
...
...
@@ -135,8 +135,61 @@ static void test_profile_string(void)
DeleteFileA
(
TESTFILE2
);
}
static
void
test_profile_sections
(
void
)
{
HANDLE
h
;
int
ret
;
DWORD
count
;
char
buf
[
100
];
WCHAR
bufW
[
100
];
static
const
char
content
[]
=
"[section1]
\r\n
[section2]
\r\n
[section3]
\r\n
"
;
static
const
char
testfile3
[]
=
".
\\
testwine3.ini"
;
static
const
WCHAR
testfile3W
[]
=
{
'.'
,
'\\'
,
't'
,
'e'
,
's'
,
't'
,
'w'
,
'i'
,
'n'
,
'e'
,
'3'
,
'.'
,
'i'
,
'n'
,
'i'
,
0
};
DeleteFileA
(
testfile3
);
h
=
CreateFileA
(
testfile3
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
ok
(
h
!=
INVALID_HANDLE_VALUE
,
" cannot create %s
\n
"
,
testfile3
);
if
(
h
==
INVALID_HANDLE_VALUE
)
return
;
WriteFile
(
h
,
content
,
sizeof
(
content
),
&
count
,
NULL
);
CloseHandle
(
h
);
/* Test with sufficiently large buffer */
ret
=
GetPrivateProfileSectionNamesA
(
buf
,
29
,
testfile3
);
ok
(
ret
==
27
,
"expected return size 27, got %d
\n
"
,
ret
);
ok
(
buf
[
ret
-
1
]
==
0
&&
buf
[
ret
]
==
0
,
"returned buffer not terminated with double-null
\n
"
);
/* Test with exactly fitting buffer */
ret
=
GetPrivateProfileSectionNamesA
(
buf
,
28
,
testfile3
);
ok
(
ret
==
26
,
"expected return size 26, got %d
\n
"
,
ret
);
ok
(
buf
[
ret
+
1
]
==
0
&&
buf
[
ret
]
==
0
,
"returned buffer not terminated with double-null
\n
"
);
/* Test with a buffer too small */
ret
=
GetPrivateProfileSectionNamesA
(
buf
,
27
,
testfile3
);
ok
(
ret
==
25
,
"expected return size 25, got %d
\n
"
,
ret
);
ok
(
buf
[
ret
+
1
]
==
0
&&
buf
[
ret
]
==
0
,
"returned buffer not terminated with double-null
\n
"
);
/* Test with sufficiently large buffer */
ret
=
GetPrivateProfileSectionNamesW
(
bufW
,
29
,
testfile3W
);
ok
(
ret
==
27
,
"expected return size 27, got %d
\n
"
,
ret
);
ok
(
buf
[
ret
-
1
]
==
0
&&
buf
[
ret
]
==
0
,
"returned buffer not terminated with double-null
\n
"
);
/* Test with exactly fitting buffer */
ret
=
GetPrivateProfileSectionNamesW
(
bufW
,
28
,
testfile3W
);
ok
(
ret
==
26
,
"expected return size 26, got %d
\n
"
,
ret
);
ok
(
buf
[
ret
+
1
]
==
0
&&
buf
[
ret
]
==
0
,
"returned buffer not terminated with double-null
\n
"
);
/* Test with a buffer too small */
ret
=
GetPrivateProfileSectionNamesW
(
bufW
,
27
,
testfile3W
);
ok
(
ret
==
25
,
"expected return size 25, got %d
\n
"
,
ret
);
ok
(
buf
[
ret
+
1
]
==
0
&&
buf
[
ret
]
==
0
,
"returned buffer not terminated with double-null
\n
"
);
DeleteFileA
(
testfile3
);
}
START_TEST
(
profile
)
{
test_profile_int
();
test_profile_string
();
test_profile_sections
();
}
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