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
58d70111
Commit
58d70111
authored
Jun 20, 2012
by
Francois Gouget
Committed by
Alexandre Julliard
Jun 20, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add line-wrapping tests for FormatMessage().
parent
91f161c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
127 additions
and
0 deletions
+127
-0
format_msg.c
dlls/kernel32/tests/format_msg.c
+127
-0
No files found.
dlls/kernel32/tests/format_msg.c
View file @
58d70111
...
...
@@ -997,6 +997,132 @@ static void test_message_ignore_inserts_wide(void)
ok
(
!
lstrcmpW
(
s_2sp
,
out
),
"Expected output string
\"
\"
, got %s
\n
"
,
wine_dbgstr_w
(
out
));
}
static
void
test_message_wrap
(
void
)
{
DWORD
ret
;
int
i
;
CHAR
in
[
300
],
out
[
300
],
ref
[
300
];
/* No need for wrapping */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
20
,
"short long line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
ok
(
ret
==
15
,
"Expected FormatMessageW to return 15, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
"short long line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* Wrap the last word */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short long line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short long
\r\n
line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* Strictly less than 10 characters per line! */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
10
,
"short long line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* Word longer than the line */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
8
,
"shortlongline"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
15
,
"Expected FormatMessageW to return 15, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"shortlon
\r\n
gline"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* Wrap the line multiple times */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
7
,
"short long line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
17
,
"Expected FormatMessageW to return 17, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long
\r\n
line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* '\n's in the source are ignored */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short
\n
long line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short long
\r\n
line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* '%n's are converted into line feeds */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short%n%nlong line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
ok
(
ret
==
18
,
"Expected FormatMessageW to return 18, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
"short
\r\n\r\n
long line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* '%n's count as starting a new line and combine with line wrapping */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
10
,
"short%nlong line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
"short
\r\n
long line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
8
,
"short%nlong line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
17
,
"Expected FormatMessageW to return 17, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long
\r\n
line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* '%r's also count as starting a new line and all */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
10
,
"short%rlong line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
ok
(
ret
==
15
,
"Expected FormatMessageW to return 15, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
"short
\r
long line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
8
,
"short%rlong line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r
long
\r\n
line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* IGNORE_INSERTS does not prevent line wrapping or disable '%n' */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
FORMAT_MESSAGE_IGNORE_INSERTS
|
8
,
"short%nlong line%1"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
19
,
"Expected FormatMessageW to return 19, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long
\r\n
line%1"
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* MAX_WIDTH_MASK is the same as specifying an infinite line width */
strcpy
(
in
,
"first line%n"
);
strcpy
(
ref
,
"first line
\r\n
"
);
for
(
i
=
0
;
i
<
26
;
i
++
)
{
strcat
(
in
,
"123456789 "
);
strcat
(
ref
,
"123456789 "
);
}
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
FORMAT_MESSAGE_MAX_WIDTH_MASK
,
in
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
ok
(
ret
==
272
,
"Expected FormatMessageW to return 272, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
ref
,
out
),
"failed out=[%s]
\n
"
,
out
);
/* Wrapping and non-space characters */
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short long
\t
line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long
\t
line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short long-line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long-line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short long_line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long_line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short long.line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long.line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short long,line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long,line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short long!line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long!line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_STRING
|
11
,
"short long?line"
,
0
,
0
,
out
,
sizeof
(
out
),
NULL
);
todo_wine
ok
(
ret
==
16
,
"Expected FormatMessageW to return 16, got %d
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
"short
\r\n
long?line"
,
out
),
"failed out=[%s]
\n
"
,
out
);
}
static
void
test_message_insufficient_buffer
(
void
)
{
static
const
char
init_buf
[]
=
{
'x'
,
'x'
,
'x'
,
'x'
,
'x'
};
...
...
@@ -1593,6 +1719,7 @@ START_TEST(format_msg)
test_message_from_string
();
test_message_ignore_inserts
();
test_message_wrap
();
test_message_insufficient_buffer
();
test_message_null_buffer
();
test_message_allocate_buffer
();
...
...
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