--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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);
+}
#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;
{
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");
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
}
--- /dev/null
+/*
+ * 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
+}
# _unloaddll.c
# _utime.c
_vsnprintf.c
-# _vsnwprintf.c
+ _vsnwprintf.c
# _wcsdup.c
# _wcsicmp.c
# _wcsicoll.c
# _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
# _vsnprintf_l.c
# _vsnprintf_s.c
# _vsnprintf_s_l.c
-# _vsnwprintf.c
+ _vsnwprintf.c
# _vsnwprintf_l.c
# _vsnwprintf_s.c
# _vsnwprintf_s_l.c
# _ui64tow.c
# _ultoa.c
# _ultow.c
-# _vscwprintf.c
+ _vscwprintf.c
_vsnprintf.c
-# _vsnwprintf.c
+ _vsnwprintf.c
# _wcsicmp.c
# _wcslwr.c
# _wcsnicmp.c
#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)
#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 }