Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-fonts
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
Aleksandr Isakov
wine-fonts
Commits
09bb38d1
Commit
09bb38d1
authored
Dec 16, 2013
by
Sebastian Lackner
Committed by
Alexandre Julliard
Dec 23, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add test for _snprintf.
parent
3c2dc4a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
string.c
dlls/ntdll/tests/string.c
+33
-0
No files found.
dlls/ntdll/tests/string.c
View file @
09bb38d1
...
...
@@ -59,6 +59,7 @@ static LPWSTR (WINAPIV *p_wcsrchr)(LPCWSTR, WCHAR);
static
void
(
__cdecl
*
p_qsort
)(
void
*
,
size_t
,
size_t
,
int
(
__cdecl
*
compar
)(
const
void
*
,
const
void
*
)
);
static
void
*
(
__cdecl
*
p_bsearch
)(
void
*
,
void
*
,
size_t
,
size_t
,
int
(
__cdecl
*
compar
)(
const
void
*
,
const
void
*
)
);
static
int
(
__cdecl
*
p__snprintf
)(
char
*
,
size_t
,
const
char
*
,
...);
static
void
InitFunctionPtrs
(
void
)
...
...
@@ -96,6 +97,8 @@ static void InitFunctionPtrs(void)
p_wcsrchr
=
(
void
*
)
GetProcAddress
(
hntdll
,
"wcsrchr"
);
p_qsort
=
(
void
*
)
GetProcAddress
(
hntdll
,
"qsort"
);
p_bsearch
=
(
void
*
)
GetProcAddress
(
hntdll
,
"bsearch"
);
p__snprintf
=
(
void
*
)
GetProcAddress
(
hntdll
,
"_snprintf"
);
}
/* if */
}
...
...
@@ -1270,6 +1273,34 @@ static void test_bsearch(void)
}
}
static
void
test__snprintf
(
void
)
{
const
char
*
origstring
=
"XXXXXXXXXXXX"
;
const
char
*
teststring
=
"hello world"
;
char
buffer
[
32
];
int
res
;
res
=
p__snprintf
(
NULL
,
0
,
teststring
);
ok
(
res
==
lstrlenA
(
teststring
),
"_snprintf returned %d, expected %d.
\n
"
,
res
,
lstrlenA
(
teststring
));
res
=
p__snprintf
(
NULL
,
1
,
teststring
);
ok
(
res
==
lstrlenA
(
teststring
)
/* WinXP */
||
res
<
0
/* Vista and greater */
,
"_snprintf returned %d, expected %d or < 0.
\n
"
,
res
,
lstrlenA
(
teststring
));
res
=
p__snprintf
(
buffer
,
strlen
(
teststring
)
-
1
,
teststring
);
ok
(
res
<
0
,
"_snprintf returned %d, expected < 0.
\n
"
,
res
);
strcpy
(
buffer
,
origstring
);
res
=
p__snprintf
(
buffer
,
strlen
(
teststring
),
teststring
);
ok
(
res
==
lstrlenA
(
teststring
),
"_snprintf returned %d, expected %d.
\n
"
,
res
,
lstrlenA
(
teststring
));
ok
(
!
strcmp
(
buffer
,
"hello worldX"
),
"_snprintf returned buffer '%s', expected 'hello worldX'.
\n
"
,
buffer
);
strcpy
(
buffer
,
origstring
);
res
=
p__snprintf
(
buffer
,
strlen
(
teststring
)
+
1
,
teststring
);
ok
(
res
==
lstrlenA
(
teststring
),
"_snprintf returned %d, expected %d.
\n
"
,
res
,
lstrlenA
(
teststring
));
ok
(
!
strcmp
(
buffer
,
teststring
),
"_snprintf returned buffer '%s', expected '%s'.
\n
"
,
buffer
,
teststring
);
}
START_TEST
(
string
)
{
InitFunctionPtrs
();
...
...
@@ -1304,4 +1335,6 @@ START_TEST(string)
test_qsort
();
if
(
p_bsearch
)
test_bsearch
();
if
(
p__snprintf
)
test__snprintf
();
}
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