2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for _vsnprintf
7 #define WIN32_NO_STATUS
11 #include <pseh/pseh2.h>
12 #include <ndk/mmfuncs.h>
13 #include <ndk/rtlfuncs.h>
15 #define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY {
16 #define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus)
18 static void call_varargs(wchar_t* buf
, size_t buf_size
, int expected_ret
, LPCWSTR formatString
, ...)
22 /* Test the basic functionality */
23 va_start(args
, formatString
);
24 ret
= _vsnwprintf(buf
, 255, formatString
, args
);
25 ok(expected_ret
== ret
, "Test failed: expected %i, got %i.\n", expected_ret
, ret
);
28 START_TEST(_vsnwprintf
)
31 NTSTATUS ExceptionStatus
;
32 /* Test basic functionality */
33 call_varargs(buffer
, 255, 19, L
"%s world!", "hello");
34 call_varargs(buffer
, 255, 12, L
"%s world!", L
"hello");
35 call_varargs(buffer
, 255, 11, L
"%u cookies", 100);
36 /* This is how WINE implements _vcsprintf, and they are obviously wrong */
38 call_varargs(NULL
, INT_MAX
, -1, L
"%s it really work?", L
"does");
39 #if defined(TEST_CRTDLL)
40 EndSeh(STATUS_ACCESS_VIOLATION
);
42 EndSeh(STATUS_SUCCESS
);
44 /* This one is no better */
46 call_varargs(NULL
, 0, -1, L
"%s it really work?", L
"does");
47 #if defined(TEST_CRTDLL)
48 EndSeh(STATUS_ACCESS_VIOLATION
);
50 EndSeh(STATUS_SUCCESS
);
52 /* One more NULL checks */
54 call_varargs(buffer
, 255, -1, NULL
);
55 #if defined(TEST_CRTDLL)
56 EndSeh(STATUS_ACCESS_VIOLATION
);
58 EndSeh(STATUS_SUCCESS
);