msvcrt: Add a test for _vsnwprintf.

Hans Leidekker hans at codeweavers.com
Tue Jan 27 04:58:49 CST 2009


diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c
index 9d31f86..d25734e 100644
--- a/dlls/msvcrt/tests/printf.c
+++ b/dlls/msvcrt/tests/printf.c
@@ -27,6 +27,10 @@
  
 #include <stdio.h>
 
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+
 #include "wine/test.h"
 
 static void test_sprintf( void )
@@ -694,10 +698,39 @@ static void test_fcvt(void)
     ok( 0 == sign, "sign wrong\n");
 }
 
+static int _vsnwprintf_wrapper(wchar_t *str, size_t len, const wchar_t *format, ...)
+{
+    int ret;
+    __ms_va_list valist;
+    __ms_va_start(valist, format);
+    ret = _vsnwprintf(str, len, format, valist);
+    __ms_va_end(valist);
+    return ret;
+}
+
+static void test_vsnwprintf(void)
+{
+    const wchar_t format[] = {'%','w','s','%','w','s','%','w','s',0};
+    const wchar_t one[]    = {'o','n','e',0};
+    const wchar_t two[]    = {'t','w','o',0};
+    const wchar_t three[]  = {'t','h','r','e','e',0};
+
+    int ret;
+    wchar_t str[32];
+    char buf[32];
+
+    ret = _vsnwprintf_wrapper( str, sizeof(str)/sizeof(str[0]), format, one, two, three );
+
+    ok( ret == 11, "got %d expected 11\n", ret );
+    WideCharToMultiByte( CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL );
+    ok( !strcmp(buf, "onetwothree"), "got %s expected 'onetwothree'\n", buf );
+}
+
 START_TEST(printf)
 {
     test_sprintf();
     test_swprintf();
     test_snprintf();
     test_fcvt();
+    test_vsnwprintf();
 }



More information about the wine-patches mailing list