Author: jgardou
Date: Sat Jul 21 20:00:56 2012
New Revision: 56928
URL:
http://svn.reactos.org/svn/reactos?rev=56928&view=rev
Log:
[APITESTS/CRT]
- Add more tests for _vsnprintf
- Add tests for _vsnwprintf, _vscprintf, _vscwprintf
Added:
trunk/rostests/apitests/crt/_vscprintf.c (with props)
trunk/rostests/apitests/crt/_vscwprintf.c (with props)
trunk/rostests/apitests/crt/_vsnwprintf.c (with props)
Modified:
trunk/rostests/apitests/crt/_vsnprintf.c
trunk/rostests/apitests/crt/crtdll_crt_apitest.cmake
trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake
trunk/rostests/apitests/crt/ntdll_crt_apitest.cmake
trunk/rostests/apitests/crt/testlist.c
Added: trunk/rostests/apitests/crt/_vscprintf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/_vscprintf.c…
==============================================================================
--- trunk/rostests/apitests/crt/_vscprintf.c (added)
+++ trunk/rostests/apitests/crt/_vscprintf.c [iso-8859-1] Sat Jul 21 20:00:56 2012
@@ -1,0 +1,29 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PURPOSE: Test for _vscprintf
+ */
+
+#include <stdio.h>
+#include <wine/test.h>
+#include <tchar.h>
+
+static void call_varargs(int expected_ret, LPCSTR formatString, ...)
+{
+ va_list args;
+ int ret;
+ /* Test the basic functionality */
+ va_start(args, formatString);
+ ret = _vscprintf(formatString, args);
+ ok(expected_ret == ret, "Test failed: expected %i, got %i.\n",
expected_ret, ret);
+}
+
+START_TEST(_vscprintf)
+{
+ /* Here you can mix wide and ANSI strings */
+ call_varargs(12, "%S world!", L"hello");
+ call_varargs(12, "%s world!", "hello");
+ call_varargs(11, "%u cookies", 100);
+ /* Test NULL argument */
+ call_varargs(-1, NULL);
+}
Propchange: trunk/rostests/apitests/crt/_vscprintf.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/crt/_vscwprintf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/_vscwprintf.…
==============================================================================
--- trunk/rostests/apitests/crt/_vscwprintf.c (added)
+++ trunk/rostests/apitests/crt/_vscwprintf.c [iso-8859-1] Sat Jul 21 20:00:56 2012
@@ -1,0 +1,30 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PURPOSE: Test for _vscprintf
+ */
+
+#include <stdio.h>
+#include <wine/test.h>
+#include <tchar.h>
+
+static void call_varargs(int expected_ret, LPCWSTR formatString, ...)
+{
+ va_list args;
+ int ret;
+ /* Test the basic functionality */
+ va_start(args, formatString);
+ ret = _vscwprintf(formatString, args);
+ ok(expected_ret == ret, "Test failed: expected %i, got %i.\n",
expected_ret, ret);
+}
+
+START_TEST(_vscwprintf)
+{
+ /* Lesson of the day: don't mix wide and ansi char */
+ call_varargs(19, L"%s world!", "hello");
+ call_varargs(12, L"%s world!", L"hello");
+ call_varargs(17, L"Jack ate %u pies", 100);
+
+ /* Test NULL argument */
+ call_varargs(-1, NULL);
+}
Propchange: trunk/rostests/apitests/crt/_vscwprintf.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/crt/_vsnprintf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/_vsnprintf.c…
==============================================================================
--- trunk/rostests/apitests/crt/_vsnprintf.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/_vsnprintf.c [iso-8859-1] Sat Jul 21 20:00:56 2012
@@ -15,7 +15,7 @@
#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,
...)
+static void call_varargs(char* buf, size_t buf_size, int expected_ret, LPCSTR
formatString, ...)
{
va_list args;
int ret;
@@ -29,8 +29,10 @@
{
char buffer[255];
NTSTATUS ExceptionStatus;
- /* Test basic functionality */
+ /* Here you can mix wide and ANSI strings */
+ call_varargs(buffer, 255, 12, "%S world!", L"hello");
call_varargs(buffer, 255, 12, "%s world!", "hello");
+ call_varargs(buffer, 255, 11, "%u cookies", 100);
/* This is how WINE implements _vcsprintf, and they are obviously wrong */
StartSeh()
call_varargs(NULL, INT_MAX, -1, "%s it really work?",
"does");
@@ -40,11 +42,19 @@
EndSeh(STATUS_SUCCESS);
#endif
/* This one is no better */
- StartSeh()
+ 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
+ /* One more NULL checks */
+ StartSeh()
+ call_varargs(buffer, 255, -1, NULL);
+#if defined(TEST_CRTDLL)
+ EndSeh(STATUS_ACCESS_VIOLATION);
+#else
+ EndSeh(STATUS_SUCCESS);
+#endif
}
Added: trunk/rostests/apitests/crt/_vsnwprintf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/_vsnwprintf.…
==============================================================================
--- trunk/rostests/apitests/crt/_vsnwprintf.c (added)
+++ trunk/rostests/apitests/crt/_vsnwprintf.c [iso-8859-1] Sat Jul 21 20:00:56 2012
@@ -1,0 +1,60 @@
+/*
+ * 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)
+
+static void call_varargs(wchar_t* buf, size_t buf_size, int expected_ret, LPCWSTR
formatString, ...)
+{
+ va_list args;
+ int ret;
+ /* Test the basic functionality */
+ va_start(args, formatString);
+ ret = _vsnwprintf(buf, 255, formatString, args);
+ ok(expected_ret == ret, "Test failed: expected %i, got %i.\n",
expected_ret, ret);
+}
+
+START_TEST(_vsnwprintf)
+{
+ wchar_t buffer[255];
+ NTSTATUS ExceptionStatus;
+ /* Test basic functionality */
+ call_varargs(buffer, 255, 19, L"%s world!", "hello");
+ call_varargs(buffer, 255, 12, L"%s world!", L"hello");
+ call_varargs(buffer, 255, 11, L"%u cookies", 100);
+ /* This is how WINE implements _vcsprintf, and they are obviously wrong */
+ StartSeh()
+ call_varargs(NULL, INT_MAX, -1, L"%s it really work?",
L"does");
+#if defined(TEST_CRTDLL)
+ EndSeh(STATUS_ACCESS_VIOLATION);
+#else
+ EndSeh(STATUS_SUCCESS);
+#endif
+ /* This one is no better */
+ StartSeh()
+ call_varargs(NULL, 0, -1, L"%s it really work?", L"does");
+#if defined(TEST_CRTDLL)
+ EndSeh(STATUS_ACCESS_VIOLATION);
+#else
+ EndSeh(STATUS_SUCCESS);
+#endif
+ /* One more NULL checks */
+ StartSeh()
+ call_varargs(buffer, 255, -1, NULL);
+#if defined(TEST_CRTDLL)
+ EndSeh(STATUS_ACCESS_VIOLATION);
+#else
+ EndSeh(STATUS_SUCCESS);
+#endif
+}
Propchange: trunk/rostests/apitests/crt/_vsnwprintf.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/crt/crtdll_crt_apitest.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/crtdll_crt_a…
==============================================================================
--- trunk/rostests/apitests/crt/crtdll_crt_apitest.cmake [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/crtdll_crt_apitest.cmake [iso-8859-1] Sat Jul 21 20:00:56
2012
@@ -315,7 +315,7 @@
# _unloaddll.c
# _utime.c
_vsnprintf.c
-# _vsnwprintf.c
+ _vsnwprintf.c
# _wcsdup.c
# _wcsicmp.c
# _wcsicoll.c
Modified: trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/msvcrt_crt_a…
==============================================================================
--- trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] Sat Jul 21 20:00:56
2012
@@ -826,10 +826,10 @@
# _vprintf_p_l
# _vprintf_s_l
# _utime.c
-# _vscprintf.c
+ _vscprintf.c
# _vscprintf_l
# _vscprintf_p_l
-# _vscwprintf.c
+ _vscwprintf.c
# _vscwprintf_l
# _vscwprintf_p_l
_vsnprintf.c
@@ -838,7 +838,7 @@
# _vsnprintf_l.c
# _vsnprintf_s.c
# _vsnprintf_s_l.c
-# _vsnwprintf.c
+ _vsnwprintf.c
# _vsnwprintf_l.c
# _vsnwprintf_s.c
# _vsnwprintf_s_l.c
Modified: trunk/rostests/apitests/crt/ntdll_crt_apitest.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/ntdll_crt_ap…
==============================================================================
--- trunk/rostests/apitests/crt/ntdll_crt_apitest.cmake [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/ntdll_crt_apitest.cmake [iso-8859-1] Sat Jul 21 20:00:56
2012
@@ -33,9 +33,9 @@
# _ui64tow.c
# _ultoa.c
# _ultow.c
-# _vscwprintf.c
+ _vscwprintf.c
_vsnprintf.c
-# _vsnwprintf.c
+ _vsnwprintf.c
# _wcsicmp.c
# _wcslwr.c
# _wcsnicmp.c
Modified: trunk/rostests/apitests/crt/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/testlist.c?r…
==============================================================================
--- trunk/rostests/apitests/crt/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/testlist.c [iso-8859-1] Sat Jul 21 20:00:56 2012
@@ -5,13 +5,22 @@
#define STANDALONE
#include "wine/test.h"
+#if defined(TEST_MSVCRT)
+extern void func__vscprintf(void);
+extern void func__vscwprintf(void);
+#endif
+#if defined(TEST_NTDLL)
+extern void func__vscwprintf(void);
+#endif
extern void func__vsnprintf(void);
+extern void func__vsnwprintf(void);
extern void func_sprintf(void);
extern void func_strcpy(void);
const struct test winetest_testlist[] =
{
{ "_vsnprintf", func__vsnprintf },
+ { "_vsnwprintf", func__vsnwprintf },
{ "sprintf", func_sprintf },
{ "strcpy", func_strcpy },
#if defined(TEST_CRTDLL) || defined(TEST_MSVCRT) || defined(TEST_STATIC_CRT)
@@ -22,7 +31,10 @@
#endif
#if defined(TEST_STATIC_CRT)
#elif defined(TEST_MSVCRT)
+ { "_vscprintf", func__vscprintf },
+ { "_vscwprintf", func__vscwprintf },
#elif defined(TEST_NTDLL)
+ { "_vscwprintf", func__vscwprintf },
#elif defined(TEST_CRTDLL)
#endif
{ 0, 0 }