Commit f2229e6d authored by Alexander Scott-Johns's avatar Alexander Scott-Johns Committed by Alexandre Julliard

msvcrt/tests: Move function pointer initialization code in printf.c into separate init function.

parent 4dff55bb
...@@ -33,6 +33,21 @@ ...@@ -33,6 +33,21 @@
#include "wine/test.h" #include "wine/test.h"
static int (__cdecl *p__vscprintf)(const char *format, __ms_va_list valist);
static int (__cdecl *p__vscwprintf)(const wchar_t *format, __ms_va_list valist);
static int (__cdecl *p__vsnwprintf_s)(wchar_t *str, size_t sizeOfBuffer,
size_t count, const wchar_t *format,
__ms_va_list valist);
static void init( void )
{
HMODULE hmod = GetModuleHandleA("msvcrt.dll");
p__vscprintf = (void *)GetProcAddress(hmod, "_vscprintf");
p__vscwprintf = (void *)GetProcAddress(hmod, "_vscwprintf");
p__vsnwprintf_s = (void *)GetProcAddress(hmod, "_vsnwprintf_s");
}
static void test_sprintf( void ) static void test_sprintf( void )
{ {
char buffer[100]; char buffer[100];
...@@ -810,12 +825,6 @@ static void test_vsnwprintf(void) ...@@ -810,12 +825,6 @@ static void test_vsnwprintf(void)
ok( !strcmp(buf, "onetwothree"), "got %s expected 'onetwothree'\n", buf ); ok( !strcmp(buf, "onetwothree"), "got %s expected 'onetwothree'\n", buf );
} }
static int (__cdecl *p__vscprintf)(const char *format, __ms_va_list valist);
static int (__cdecl *p__vscwprintf)(const wchar_t *format, __ms_va_list valist);
static int (__cdecl *p__vsnwprintf_s)(wchar_t *str, size_t sizeOfBuffer,
size_t count, const wchar_t *format,
__ms_va_list valist);
static int __cdecl _vscprintf_wrapper(const char *format, ...) static int __cdecl _vscprintf_wrapper(const char *format, ...)
{ {
int ret; int ret;
...@@ -830,6 +839,12 @@ static void test_vscprintf(void) ...@@ -830,6 +839,12 @@ static void test_vscprintf(void)
{ {
int ret; int ret;
if (!p__vscprintf)
{
win_skip("_vscprintf not available\n");
return;
}
ret = _vscprintf_wrapper( "%s %d", "number", 1 ); ret = _vscprintf_wrapper( "%s %d", "number", 1 );
ok( ret == 8, "got %d expected 8\n", ret ); ok( ret == 8, "got %d expected 8\n", ret );
} }
...@@ -851,6 +866,12 @@ static void test_vscwprintf(void) ...@@ -851,6 +866,12 @@ static void test_vscwprintf(void)
int ret; int ret;
if (!p__vscwprintf)
{
win_skip("_vscwprintf not available\n");
return;
}
ret = _vscwprintf_wrapper( format, number, 1 ); ret = _vscwprintf_wrapper( format, number, 1 );
ok( ret == 8, "got %d expected 8\n", ret ); ok( ret == 8, "got %d expected 8\n", ret );
} }
...@@ -876,6 +897,12 @@ static void test_vsnwprintf_s(void) ...@@ -876,6 +897,12 @@ static void test_vsnwprintf_s(void)
wchar_t buffer[14] = { 0 }; wchar_t buffer[14] = { 0 };
int exp, got; int exp, got;
if (!p__vsnwprintf_s)
{
win_skip("_vsnwprintf_s not available\n");
return;
}
/* Enough room. */ /* Enough room. */
exp = wcslen(out7); exp = wcslen(out7);
...@@ -909,29 +936,15 @@ static void test_vsnwprintf_s(void) ...@@ -909,29 +936,15 @@ static void test_vsnwprintf_s(void)
START_TEST(printf) START_TEST(printf)
{ {
init();
test_sprintf(); test_sprintf();
test_swprintf(); test_swprintf();
test_snprintf(); test_snprintf();
test_fcvt(); test_fcvt();
test_xcvt(); test_xcvt();
test_vsnwprintf(); test_vsnwprintf();
test_vscprintf();
p__vscprintf = (void *)GetProcAddress(GetModuleHandle("msvcrt.dll"), "_vscprintf"); test_vscwprintf();
p__vscwprintf = (void *)GetProcAddress(GetModuleHandle("msvcrt.dll"), "_vscwprintf"); test_vsnwprintf_s();
p__vsnwprintf_s = (void *)GetProcAddress(GetModuleHandle("msvcrt.dll"), "_vsnwprintf_s");
if (p__vscprintf)
test_vscprintf();
else
win_skip("_vscprintf not available\n");
if (p__vscwprintf)
test_vscwprintf();
else
win_skip("_vscwprintf not available\n");
if (p__vsnwprintf_s)
test_vsnwprintf_s();
else
win_skip("_vsnwprintf_s not available\n");
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment