diff --git a/rostests/apitests/crt/_vsnprintf.c b/rostests/apitests/crt/_vsnprintf.c new file mode 100644 index 00000000000..a6b116559c6 --- /dev/null +++ b/rostests/apitests/crt/_vsnprintf.c @@ -0,0 +1,50 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for _vsnprintf + */ + +#define WIN32_NO_STATUS +#include +#include +#include +#include +#include +#include + +#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY { +#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus) + +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]; + NTSTATUS ExceptionStatus; + /* Test basic functionality */ + call_varargs(buffer, 255, 12, "%s world!", "hello"); + /* This is how WINE implements _vcsprintf, and they are obviously wrong */ + StartSeh() + call_varargs(NULL, INT_MAX, -1, "%s it really work?", "does"); +#if defined(TEST_CRTDLL) || defined(TEST_USER32) + EndSeh(STATUS_ACCESS_VIOLATION); +#else + EndSeh(STATUS_SUCCESS); +#endif + /* This one is no better */ + StartSeh() + call_varargs(NULL, 0, -1, "%s it really work?", "does"); +#if defined(TEST_CRTDLL) || defined(TEST_USER32) + EndSeh(STATUS_ACCESS_VIOLATION); +#else + EndSeh(STATUS_SUCCESS); +#endif +} diff --git a/rostests/apitests/crt/crtdll_crt_apitest.cmake b/rostests/apitests/crt/crtdll_crt_apitest.cmake index f739fb50ed9..5cf8dd26ee1 100644 --- a/rostests/apitests/crt/crtdll_crt_apitest.cmake +++ b/rostests/apitests/crt/crtdll_crt_apitest.cmake @@ -314,7 +314,7 @@ list(APPEND SOURCE_CRTDLL # _unlink.c # _unloaddll.c # _utime.c -# _vsnprintf.c + _vsnprintf.c # _vsnwprintf.c # _wcsdup.c # _wcsicmp.c diff --git a/rostests/apitests/crt/msvcrt_crt_apitest.cmake b/rostests/apitests/crt/msvcrt_crt_apitest.cmake index 5c75c235a09..3994110f1f1 100644 --- a/rostests/apitests/crt/msvcrt_crt_apitest.cmake +++ b/rostests/apitests/crt/msvcrt_crt_apitest.cmake @@ -832,7 +832,7 @@ list(APPEND SOURCE_MSVCRT # _vscwprintf.c # _vscwprintf_l # _vscwprintf_p_l -# _vsnprintf.c + _vsnprintf.c # _vsnprintf_c.c _vsnprintf # _vsnprintf_c_l.c _vsnprintf_l # _vsnprintf_l.c diff --git a/rostests/apitests/crt/ntdll_crt_apitest.cmake b/rostests/apitests/crt/ntdll_crt_apitest.cmake index 3b3560ec3b9..55421141ec1 100644 --- a/rostests/apitests/crt/ntdll_crt_apitest.cmake +++ b/rostests/apitests/crt/ntdll_crt_apitest.cmake @@ -34,7 +34,7 @@ list(APPEND SOURCE_NTDLL # _ultoa.c # _ultow.c # _vscwprintf.c -# _vsnprintf.c + _vsnprintf.c # _vsnwprintf.c # _wcsicmp.c # _wcslwr.c diff --git a/rostests/apitests/crt/testlist.c b/rostests/apitests/crt/testlist.c index 4c2546cf60a..780c73954c3 100644 --- a/rostests/apitests/crt/testlist.c +++ b/rostests/apitests/crt/testlist.c @@ -5,11 +5,13 @@ #define STANDALONE #include "wine/test.h" +extern void func__vsnprintf(void); extern void func_sprintf(void); extern void func_strcpy(void); const struct test winetest_testlist[] = { + { "_vsnprintf", func__vsnprintf }, { "sprintf", func_sprintf }, { "strcpy", func_strcpy }, #if defined(TEST_CRTDLL) || defined(TEST_MSVCRT) || defined(TEST_STATIC_CRT) diff --git a/rostests/apitests/msvcrt/CMakeLists.txt b/rostests/apitests/msvcrt/CMakeLists.txt index c4a9d8618d3..59c6772b378 100644 --- a/rostests/apitests/msvcrt/CMakeLists.txt +++ b/rostests/apitests/msvcrt/CMakeLists.txt @@ -2,7 +2,6 @@ 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 deleted file mode 100644 index d345c6b96d2..00000000000 --- a/rostests/apitests/msvcrt/_vsnprintf.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 d0b2c866465..0e57890b48f 100644 --- a/rostests/apitests/msvcrt/testlist.c +++ b/rostests/apitests/msvcrt/testlist.c @@ -5,13 +5,11 @@ #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 },