1 /* Simple test of putwc in the C locale.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
27 static const char outname
[] = OBJPFX
"tst_putwc.temp";
30 #define TEST_FUNCTION do_test ()
34 const wchar_t str
[] = L
"This is a test of putwc\n";
40 fp
= fopen (outname
, "w+");
42 error (EXIT_FAILURE
, errno
, "cannot open temporary file");
44 for (n
= 0; str
[n
] != L
'\0'; ++n
)
47 /* First try reading after rewinding. */
50 wmemset (buf
, L
'\0', sizeof (buf
) / sizeof (buf
[0]));
52 while (! feof (fp
) && n
< sizeof (buf
) - 1)
61 if (wcscmp (buf
, L
"This is a test of putwc\n") != 0)
63 puts ("first comparison failed");
67 /* Now close the file, open it again, and read again. */
70 printf ("failure during fclose(): %m");
74 fp
= fopen (outname
, "r");
76 error (EXIT_FAILURE
, errno
, "cannot reopen file");
78 /* We can remove the file now. */
81 wmemset (buf
, L
'\0', sizeof (buf
) / sizeof (buf
[0]));
83 while (! feof (fp
) && n
< sizeof (buf
) - 1)
92 if (wcscmp (buf
, L
"This is a test of putwc\n") != 0)
94 puts ("second comparison failed");
100 puts ("failure during fclose()");
104 /* Next test: write a bit more than a few bytes. */
105 fp
= fopen (outname
, "w");
107 error (EXIT_FAILURE
, errno
, "cannot open temporary file");
109 for (n
= 0; n
< 4098; ++n
)
118 #include "../test-skeleton.c"