xref: /haiku/src/tests/system/libroot/posix/fwide_test.c (revision 25a7b01d15612846f332751841da3579db313082)
1c824d9d6SOliver Tappe /*
2c824d9d6SOliver Tappe  * Copyright 2012, Oliver Tappe, zooey@hirschkaefer.de
3c824d9d6SOliver Tappe  * Distributed under the terms of the MIT License.
4c824d9d6SOliver Tappe  */
5c824d9d6SOliver Tappe 
6b3482508SOliver Tappe #include <locale.h>
7c824d9d6SOliver Tappe #include <stdio.h>
8c824d9d6SOliver Tappe #include <wchar.h>
9c824d9d6SOliver Tappe 
10c824d9d6SOliver Tappe 
11c824d9d6SOliver Tappe int
main(int argc,char ** argv)12c824d9d6SOliver Tappe main(int argc, char** argv)
13c824d9d6SOliver Tappe {
14c824d9d6SOliver Tappe 	int result = 0;
15c824d9d6SOliver Tappe 
16c824d9d6SOliver Tappe 	fprintf(stdout, "stdout should now be set to non-wide mode ...\n");
17c824d9d6SOliver Tappe 	result = fwide(stdout, 0);
18c824d9d6SOliver Tappe 	if (result != -1)
19c824d9d6SOliver Tappe 	{
20c824d9d6SOliver Tappe 		printf("PROBLEM: fwide(stdout, 0) = %d (expected -1)\n", result);
21c824d9d6SOliver Tappe 	}
22c824d9d6SOliver Tappe 
23*be601bbbSOliver Tappe 	fwprintf(stderr, L"stderr should now be set to wide mode ...\n");
24c824d9d6SOliver Tappe 	result = fwide(stderr, 0);
25c824d9d6SOliver Tappe 	if (result != 1)
26c824d9d6SOliver Tappe 	{
27c824d9d6SOliver Tappe 		printf("PROBLEM: fwide(stderr, 0) = %d (expected -1)\n", result);
28c824d9d6SOliver Tappe 	}
29c824d9d6SOliver Tappe 
30c824d9d6SOliver Tappe 	fprintf(stderr, "%s", "this should *not* be visible!\n");
31c824d9d6SOliver Tappe 	fwprintf(stdout, L"%ls", L"this should *not* be visible!\n");
32c824d9d6SOliver Tappe 
33c824d9d6SOliver Tappe 	fprintf(stderr, "%ls", L"this should *not* be visible!\n");
34c824d9d6SOliver Tappe 	fwprintf(stdout, L"%s", "this should *not* be visible!\n");
35c824d9d6SOliver Tappe 
36c824d9d6SOliver Tappe 	fprintf(stdout, "%ls", L"this *should* be visible!\n");
37c824d9d6SOliver Tappe 	fwprintf(stderr, L"%s", "this *should* be visible!\n");
38c824d9d6SOliver Tappe 
39c824d9d6SOliver Tappe 	fprintf(stdout, "%s", "this *should* be visible!\n");
40c824d9d6SOliver Tappe 	fwprintf(stderr, L"%ls", L"this *should* be visible!\n");
41c824d9d6SOliver Tappe 
42b3482508SOliver Tappe 	setlocale(LC_ALL, "");
43b3482508SOliver Tappe 
44b3482508SOliver Tappe 	fprintf(stderr, "%s", "this should *not* be visible!\n");
45b3482508SOliver Tappe 	fwprintf(stdout, L"%ls", L"this should *not* be visible!\n");
46b3482508SOliver Tappe 
47b3482508SOliver Tappe 	fprintf(stderr, "%ls", L"this should *not* be visible!\n");
48b3482508SOliver Tappe 	fwprintf(stdout, L"%s", "this should *not* be visible!\n");
49b3482508SOliver Tappe 
50b3482508SOliver Tappe 	fprintf(stdout, "%ls", L"this *should* be visible! (äöúß)\n");
51b3482508SOliver Tappe 	fwprintf(stderr, L"%s", "this *should* be visible! (äöúß)\n");
52b3482508SOliver Tappe 
53b3482508SOliver Tappe 	fprintf(stdout, "%s", "this *should* be visible! (äöúß)\n");
54b3482508SOliver Tappe 	fwprintf(stderr, L"%ls", L"this *should* be visible! (äöúß)\n");
55b3482508SOliver Tappe 
56c824d9d6SOliver Tappe 	return 0;
57c824d9d6SOliver Tappe }
58