[APITESTS]

- Move _vsnprintf to crt tests, where it belongs, and make it pass for crtdll

svn path=/trunk/; revision=56925
This commit is contained in:
Jérôme Gardou
2012-07-21 17:15:08 +00:00
parent 7ee4b9f4f0
commit f505107ac2
8 changed files with 55 additions and 38 deletions
+50
View File
@@ -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 <stdio.h>
#include <wine/test.h>
#include <tchar.h>
#include <pseh/pseh2.h>
#include <ndk/mmfuncs.h>
#include <ndk/rtlfuncs.h>
#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
}
@@ -314,7 +314,7 @@ list(APPEND SOURCE_CRTDLL
# _unlink.c
# _unloaddll.c
# _utime.c
# _vsnprintf.c
_vsnprintf.c
# _vsnwprintf.c
# _wcsdup.c
# _wcsicmp.c
@@ -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
@@ -34,7 +34,7 @@ list(APPEND SOURCE_NTDLL
# _ultoa.c
# _ultow.c
# _vscwprintf.c
# _vsnprintf.c
_vsnprintf.c
# _vsnwprintf.c
# _wcsicmp.c
# _wcslwr.c
+2
View File
@@ -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)
-1
View File
@@ -2,7 +2,6 @@
add_definitions(-D_DLL -D__USE_CRTIMP)
list(APPEND SOURCE
_vsnprintf.c
ieee.c
splitpath.c
testlist.c)
-32
View File
@@ -1,32 +0,0 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: GPL - See COPYING in the top level directory
* PURPOSE: Test for _vsnprintf
*/
#include <wine/test.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <stdarg.h>
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");
}
-2
View File
@@ -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 },