2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for _vsnprintf
9 #define WIN32_NO_STATUS
12 #include <pseh/pseh2.h>
13 #include <ndk/mmfuncs.h>
14 #include <ndk/rtlfuncs.h>
16 static void call_varargs(wchar_t* buf
, size_t buf_size
, int expected_ret
, LPCWSTR formatString
, ...)
20 /* Test the basic functionality */
21 va_start(args
, formatString
);
22 ret
= _vsnwprintf(buf
, buf_size
, formatString
, args
);
23 ok(expected_ret
== ret
, "Test failed: expected %i, got %i.\n", expected_ret
, ret
);
26 START_TEST(_vsnwprintf
)
30 /* Test basic functionality */
31 call_varargs(buffer
, 255, 19, L
"%s world!", "hello");
32 call_varargs(buffer
, 255, 12, L
"%s world!", L
"hello");
33 call_varargs(buffer
, 255, 11, L
"%u cookies", 100);
34 /* This is how WINE implements _vcsprintf, and they are obviously wrong */
36 call_varargs(NULL
, INT_MAX
, -1, L
"%s it really work?", L
"does");
37 #if defined(TEST_CRTDLL)
38 EndSeh(STATUS_ACCESS_VIOLATION
);
40 EndSeh(STATUS_SUCCESS
);
42 #if defined(TEST_MSVCRT) /* NTDLL doesn't use/set errno */
43 ok(errno
== EINVAL
, "Expected EINVAL, got %u\n", errno
);
45 /* This one is no better */
47 call_varargs(NULL
, 0, -1, L
"%s it really work?", L
"does");
48 #if defined(TEST_CRTDLL)
49 EndSeh(STATUS_ACCESS_VIOLATION
);
51 EndSeh(STATUS_SUCCESS
);
53 #if defined(TEST_MSVCRT) /* NTDLL doesn't use/set errno */
54 ok(errno
== EINVAL
, "Expected EINVAL, got %u\n", errno
);
56 /* One more NULL checks */
58 call_varargs(buffer
, 255, -1, NULL
);
59 #if defined(TEST_CRTDLL)
60 EndSeh(STATUS_ACCESS_VIOLATION
);
62 EndSeh(STATUS_SUCCESS
);
64 #if defined(TEST_MSVCRT) /* NTDLL doesn't use/set errno */
65 ok(errno
== EINVAL
, "Expected EINVAL, got %u\n", errno
);