Add test for fwide() and wide/non-wide streams.

This commit is contained in:
Oliver Tappe 2012-01-29 19:45:34 +01:00
parent e01182d02f
commit c824d9d6ed
2 changed files with 43 additions and 0 deletions

View File

@ -37,6 +37,7 @@ SimpleTest xsi_msg_queue_test1 : xsi_msg_queue_test1.cpp ;
SimpleTest xsi_sem_test1 : xsi_sem_test1.cpp ;
# wide character tests
SimpleTest fwide_test : fwide_test.c ;
SimpleTest gnulib-test-btowc : gnulib-test-btowc.c ;
SimpleTest gnulib-test-mbrtowc : gnulib-test-mbrtowc.c ;
#SimpleTest gnulib-test-mbsnrtowcs : gnulib-test-mbsnrtowcs.c ;

View File

@ -0,0 +1,42 @@
/*
* Copyright 2012, Oliver Tappe, zooey@hirschkaefer.de
* Distributed under the terms of the MIT License.
*/
#include <stdio.h>
#include <wchar.h>
int
main(int argc, char** argv)
{
int result = 0;
fprintf(stdout, "stdout should now be set to non-wide mode ...\n");
result = fwide(stdout, 0);
if (result != -1)
{
printf("PROBLEM: fwide(stdout, 0) = %d (expected -1)\n", result);
}
fwprintf(stderr, L"stderr should now be set to non-wide mode ...\n");
result = fwide(stderr, 0);
if (result != 1)
{
printf("PROBLEM: fwide(stderr, 0) = %d (expected -1)\n", result);
}
fprintf(stderr, "%s", "this should *not* be visible!\n");
fwprintf(stdout, L"%ls", L"this should *not* be visible!\n");
fprintf(stderr, "%ls", L"this should *not* be visible!\n");
fwprintf(stdout, L"%s", "this should *not* be visible!\n");
fprintf(stdout, "%ls", L"this *should* be visible!\n");
fwprintf(stderr, L"%s", "this *should* be visible!\n");
fprintf(stdout, "%s", "this *should* be visible!\n");
fwprintf(stderr, L"%ls", L"this *should* be visible!\n");
return 0;
}