msvcrt: Added fwprintf tests.
This commit is contained in:
parent
c1792e1a8a
commit
8401224731
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue