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