Piotr Caban : msvcrt: Added fwprintf tests.
Alexandre Julliard
julliard at winehq.org
Fri Jan 11 13:46:58 CST 2013
Module: wine
Branch: master
Commit: 840122473161cb334c04bf2bd0b5777f8521d426
URL: http://source.winehq.org/git/wine.git/?a=commit;h=840122473161cb334c04bf2bd0b5777f8521d426
Author: Piotr Caban <piotr at codeweavers.com>
Date: Fri Jan 11 11:20:03 2013 +0100
msvcrt: Added fwprintf tests.
---
dlls/msvcrt/tests/printf.c | 54 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 53 insertions(+), 1 deletions(-)
diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c
index 7780327..0d4a241 100644
--- a/dlls/msvcrt/tests/printf.c
+++ b/dlls/msvcrt/tests/printf.c
@@ -691,7 +691,9 @@ static void test_snprintf (void)
static void test_fprintf(void)
{
- static char file_name[] = "fprintf.tst";
+ static const char file_name[] = "fprintf.tst";
+ static const WCHAR utf16_test[] = {'u','n','i','c','o','d','e','\n',0};
+
FILE *fp = fopen(file_name, "wb");
char buf[1024];
int ret;
@@ -706,6 +708,11 @@ static void test_fprintf(void)
ret = ftell(fp);
ok(ret == 26, "ftell returned %d\n", ret);
+ ret = fwprintf(fp, utf16_test);
+ ok(ret == 8, "ret = %d\n", ret);
+ ret = ftell(fp);
+ ok(ret == 42, "ftell returned %d\n", ret);
+
fclose(fp);
fp = fopen(file_name, "rb");
@@ -720,6 +727,51 @@ static void test_fprintf(void)
ok(ret == 26, "ret = %d\n", ret);
ok(!memcmp(buf, "contains\0null\n", 14), "buf = %s\n", buf);
+ memset(buf, 0, sizeof(buf));
+ fgets(buf, sizeof(buf), fp);
+ ret = ftell(fp);
+ ok(ret == 41, "ret = %d\n", ret);
+ ok(!memcmp(buf, utf16_test, sizeof(utf16_test)),
+ "buf = %s\n", wine_dbgstr_w((WCHAR*)buf));
+
+ fclose(fp);
+
+ fp = fopen(file_name, "wt");
+
+ ret = fprintf(fp, "simple test\n");
+ ok(ret == 12, "ret = %d\n", ret);
+ ret = ftell(fp);
+ ok(ret == 13, "ftell returned %d\n", ret);
+
+ ret = fprintf(fp, "contains%cnull\n", '\0');
+ ok(ret == 14, "ret = %d\n", ret);
+ ret = ftell(fp);
+ ok(ret == 28, "ftell returned %d\n", ret);
+
+ ret = fwprintf(fp, utf16_test);
+ ok(ret == 8, "ret = %d\n", ret);
+ ret = ftell(fp);
+ ok(ret == 37, "ftell returned %d\n", ret);
+
+ fclose(fp);
+
+ fp = fopen(file_name, "rb");
+ ret = fscanf(fp, "%[^\n] ", buf);
+ ok(ret == 1, "ret = %d\n", ret);
+ ret = ftell(fp);
+ ok(ret == 13, "ftell returned %d\n", ret);
+ ok(!strcmp(buf, "simple test\r"), "buf = %s\n", buf);
+
+ fgets(buf, sizeof(buf), fp);
+ ret = ftell(fp);
+ ok(ret == 28, "ret = %d\n", ret);
+ ok(!memcmp(buf, "contains\0null\r\n", 15), "buf = %s\n", buf);
+
+ fgets(buf, sizeof(buf), fp);
+ ret = ftell(fp);
+ ok(ret == 37, "ret = %d\n", ret);
+ ok(!strcmp(buf, "unicode\r\n"), "buf = %s\n", buf);
+
fclose(fp);
unlink(file_name);
}
More information about the wine-cvs
mailing list