Author: jgardou Date: Sat Jul 21 16:31:03 2012 New Revision: 56924
URL: http://svn.reactos.org/svn/reactos?rev=56924&view=rev Log: [MSVCRT_APITEST] - add basic test for _vsnprintf This is mostly to verify if WINE's implementation of _vcsprintf is correct
Added: trunk/rostests/apitests/msvcrt/_vsnprintf.c (with props) Modified: trunk/rostests/apitests/msvcrt/CMakeLists.txt trunk/rostests/apitests/msvcrt/testlist.c
Modified: trunk/rostests/apitests/msvcrt/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msvcrt/CMakeLists... ============================================================================== --- trunk/rostests/apitests/msvcrt/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/msvcrt/CMakeLists.txt [iso-8859-1] Sat Jul 21 16:31:03 2012 @@ -2,6 +2,7 @@ add_definitions(-D_DLL -D__USE_CRTIMP)
list(APPEND SOURCE + _vsnprintf.c ieee.c splitpath.c testlist.c)
Added: trunk/rostests/apitests/msvcrt/_vsnprintf.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msvcrt/_vsnprintf... ============================================================================== --- trunk/rostests/apitests/msvcrt/_vsnprintf.c (added) +++ trunk/rostests/apitests/msvcrt/_vsnprintf.c [iso-8859-1] Sat Jul 21 16:31:03 2012 @@ -1,0 +1,32 @@ +/* + * 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"); +}
Propchange: trunk/rostests/apitests/msvcrt/_vsnprintf.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/rostests/apitests/msvcrt/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msvcrt/testlist.c... ============================================================================== --- trunk/rostests/apitests/msvcrt/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/msvcrt/testlist.c [iso-8859-1] Sat Jul 21 16:31:03 2012 @@ -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 },