ReactOS 0.4.16-dev-1946-g52006dd
_vsnprintf.c File Reference
#include <apitest.h>
#include <stdio.h>
#include <tchar.h>
#include <pseh/pseh2.h>
#include <ndk/mmfuncs.h>
#include <ndk/rtlfuncs.h>
Include dependency graph for _vsnprintf.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _vsnprintf   p_vsnprintf
 

Typedefs

typedef int(__cdeclPFN_vsnprintf) (char *buf, size_t cnt, const char *fmt, va_list args)
 

Functions

static BOOL Init (void)
 
static void call_varargs (char *buf, size_t buf_size, int expected_ret, LPCSTR formatString,...)
 
 START_TEST (_vsnprintf)
 

Variables

static PFN_vsnprintf p_vsnprintf
 

Macro Definition Documentation

◆ _vsnprintf

#define _vsnprintf   p_vsnprintf

Definition at line 28 of file _vsnprintf.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 9 of file _vsnprintf.c.

Typedef Documentation

◆ PFN_vsnprintf

typedef int(__cdecl * PFN_vsnprintf) (char *buf, size_t cnt, const char *fmt, va_list args)

Definition at line 18 of file _vsnprintf.c.

Function Documentation

◆ call_varargs()

static void call_varargs ( char buf,
size_t  buf_size,
int  expected_ret,
LPCSTR  formatString,
  ... 
)
static

Definition at line 32 of file _vsnprintf.c.

33{
35 int ret;
36 /* Test the basic functionality */
37 va_start(args, formatString);
38 ret = _vsnprintf(buf, buf_size, formatString, args);
39 va_end(args);
40 ok(expected_ret == ret, "Test failed for `%s`: expected %i, got %i.\n", formatString, expected_ret, ret);
41}
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
return ret
Definition: mutex.c:146
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define _vsnprintf
Definition: _vsnprintf.c:28
#define args
Definition: format.c:66
Definition: match.c:390

Referenced by START_TEST().

◆ Init()

static BOOL Init ( void  )
static

Definition at line 21 of file _vsnprintf.c.

22{
25 ok(p_vsnprintf != NULL, "Failed to load _vsnprintf from %s\n", TEST_DLL_NAME);
26 return (p_vsnprintf != NULL);
27}
#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
static PFN_vsnprintf p_vsnprintf
Definition: _vsnprintf.c:19
int(__cdecl * PFN_vsnprintf)(char *buf, size_t cnt, const char *fmt, va_list args)
Definition: _vsnprintf.c:18
#define TEST_DLL_NAME
Definition: wsprintf.c:3
static PVOID hdll
Definition: shimdbg.c:126

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( _vsnprintf  )

Definition at line 43 of file _vsnprintf.c.

44{
45 char buffer[255];
46
47#ifndef TEST_STATIC_CRT
48 if (!Init())
49 {
50 skip("Skipping tests, because _vsnprintf is not available\n");
51 return;
52 }
53#endif
54
55 /* Here you can mix wide and ANSI strings */
56 call_varargs(buffer, 255, 12, "%S world!", L"hello");
57 call_varargs(buffer, 255, 12, "%s world!", "hello");
58 call_varargs(buffer, 255, 11, "%u cookies", 100);
59
60 StartSeh()
61#if defined(TEST_CRTDLL)||defined(TEST_USER32)
62 call_varargs(NULL, INT_MAX, -1, "%s it really work?", "does");
63#else
65 call_varargs(NULL, INT_MAX, -1, "%s it really work?", "does");
66 else
67 call_varargs(NULL, INT_MAX, 20, "%s it really work?", "does");
68#endif
69
70#if defined(TEST_CRTDLL)||defined(TEST_USER32)
72#else
74#endif
75
76#if defined(TEST_USER32)
78#elif defined(TEST_NTDLL) || defined(TEST_CRTDLL)
79 ok_eq_uint(errno, 0);
80#else
83 else
84 ok_eq_uint(errno, 0);
85#endif
86
87 /* This one is no better */
88 StartSeh()
89#if defined(TEST_CRTDLL)||defined(TEST_USER32)
90 call_varargs(NULL, 0, -1, "%s it really work?", "does");
91#else
92 call_varargs(NULL, 0, 20, "%s it really work?", "does");
93#endif
94
95#if defined(TEST_USER32)
97#else
99#endif
100
101#if defined(TEST_USER32)
103#elif defined(TEST_NTDLL) || defined(TEST_CRTDLL)
104 ok_eq_uint(errno, 0);
105#else
108 else
109 ok_eq_uint(errno, 0);
110#endif
111
112 /* One more NULL checks */
113 StartSeh()
114 call_varargs(buffer, 255, -1, NULL);
115#if defined(TEST_CRTDLL)
117#else
119#endif
120
121#if defined(TEST_USER32)
123#elif defined(TEST_NTDLL) || defined(TEST_CRTDLL)
124 ok_eq_uint(errno, 0);
125#else
128 else
129 ok_eq_uint(errno, 0);
130#endif
131}
#define EINVAL
Definition: acclib.h:90
#define GetNTVersion()
Definition: apitest.h:17
#define ok_eq_uint(value, expected)
Definition: apitest.h:118
#define StartSeh()
Definition: apitest.h:93
#define EndSeh(ExpectedStatus)
Definition: apitest.h:99
#define skip(...)
Definition: atltest.h:64
#define L(x)
Definition: resources.c:13
#define STATUS_ACCESS_VIOLATION
GLuint buffer
Definition: glext.h:5915
#define INT_MAX
Definition: intsafe.h:150
static BOOL Init(void)
Definition: _vsnprintf.c:21
static void call_varargs(char *buf, size_t buf_size, int expected_ret, LPCSTR formatString,...)
Definition: _vsnprintf.c:32
#define errno
Definition: errno.h:18
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ERROR_BAD_COMMAND
Definition: winerror.h:247

Variable Documentation

◆ p_vsnprintf

PFN_vsnprintf p_vsnprintf
static

Definition at line 19 of file _vsnprintf.c.

Referenced by Init().