ReactOS 0.4.16-dev-1946-g52006dd
_vscprintf.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for _vscprintf
5 */
6
7#include <apitest.h>
8
9#include <stdio.h>
10#include <tchar.h>
11#include <errno.h>
12
13#ifndef TEST_STATIC_CRT
14
15typedef int (__cdecl *PFN_vscprintf)(const char *format, va_list argptr);
17
18static BOOL Init(void)
19{
22 ok(p_vscprintf != NULL, "Failed to load _vscprintf from %s\n", TEST_DLL_NAME);
23 return (p_vscprintf != NULL);
24}
25#define _vscprintf p_vscprintf
26
27#endif // !TEST_STATIC_CRT
28
29static void call_varargs(int expected_ret, LPCSTR formatString, ...)
30{
32 int ret;
33 /* Test the basic functionality */
34 va_start(args, formatString);
35 ret = _vscprintf(formatString, args);
36 va_end(args);
37 ok(expected_ret == ret, "Test failed: expected %i, got %i.\n", expected_ret, ret);
38}
39
41{
42#ifndef TEST_STATIC_CRT
43 if (!Init())
44 {
45 skip("Skipping tests, because _vscprintf is not available\n");
46 return;
47 }
48#endif
49
50 /* Here you can mix wide and ANSI strings */
51 call_varargs(12, "%S world!", L"hello");
52 call_varargs(12, "%s world!", "hello");
53 call_varargs(11, "%u cookies", 100);
54 /* Do not test NULL argument. That is verified to SEGV on a */
55 /* release-build with VC10 and MS' msvcrt. */
56}
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _vscprintf
Definition: _vscprintf.c:25
int(__cdecl * PFN_vscprintf)(const char *format, va_list argptr)
Definition: _vscprintf.c:15
static BOOL Init(void)
Definition: _vscprintf.c:18
static void call_varargs(int expected_ret, LPCSTR formatString,...)
Definition: _vscprintf.c:29
static PFN_vscprintf p_vscprintf
Definition: _vscprintf.c:16
#define TEST_DLL_NAME
Definition: wsprintf.c:3
#define args
Definition: format.c:66
static PVOID hdll
Definition: shimdbg.c:126
Definition: match.c:390
Definition: format.c:58
const char * LPCSTR
Definition: xmlstorage.h:183