diff --git a/rostests/apitests/msvcrt/CMakeLists.txt b/rostests/apitests/msvcrt/CMakeLists.txt index 59c6772b378..c4a9d8618d3 100644 --- a/rostests/apitests/msvcrt/CMakeLists.txt +++ b/rostests/apitests/msvcrt/CMakeLists.txt @@ -2,6 +2,7 @@ add_definitions(-D_DLL -D__USE_CRTIMP) list(APPEND SOURCE + _vsnprintf.c ieee.c splitpath.c testlist.c) diff --git a/rostests/apitests/msvcrt/_vsnprintf.c b/rostests/apitests/msvcrt/_vsnprintf.c new file mode 100644 index 00000000000..d345c6b96d2 --- /dev/null +++ b/rostests/apitests/msvcrt/_vsnprintf.c @@ -0,0 +1,32 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for _vsnprintf + */ + +#include +#include +#include +#include +#include + +void call_varargs(char* buf, size_t buf_size, int expected_ret, LPCSTR formatString, ...) +{ + va_list args; + int ret; + /* Test the basic functionality */ + va_start(args, formatString); + ret = _vsnprintf(buf, 255, formatString, args); + ok(expected_ret == ret, "Test failed: expected %i, got %i.\n", expected_ret, ret); +} + +START_TEST(_vsnprintf) +{ + char buffer[255]; + /* Test basic functionality */ + call_varargs(buffer, 255, 12, "%s world!", "hello"); + /* This is how WINE implements _vcsprintf, and they are obviously wrong */ + call_varargs(NULL, INT_MAX, -1, "%s it really work?", "does"); + /* This one is no better */ + call_varargs(NULL, 0, -1, "%s it really work?", "does"); +} diff --git a/rostests/apitests/msvcrt/testlist.c b/rostests/apitests/msvcrt/testlist.c index 0e57890b48f..d0b2c866465 100644 --- a/rostests/apitests/msvcrt/testlist.c +++ b/rostests/apitests/msvcrt/testlist.c @@ -5,11 +5,13 @@ #define STANDALONE #include "wine/test.h" +extern void func__vsnprintf(void); extern void func_ieee(void); extern void func_splitpath(void); const struct test winetest_testlist[] = { + { "_vsnprintf", func__vsnprintf}, { "ieee", func_ieee }, { "splitpath", func_splitpath },