nstrftime, c-nstrftime tests: Avoid test failures on native Windows.
[gnulib.git] / tests / test-mbfile.c
blob1d857a819b58432b2cee55184d5f2f10255a7a8c
1 /* Test of multibyte character I/O.
2 Copyright (C) 2023-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2023. */
19 #include <config.h>
21 #include "mbfile.h"
23 #include <locale.h>
25 #include "macros.h"
27 int
28 main ()
30 if (setlocale (LC_ALL, "en_US.UTF-8") == NULL)
32 fprintf (stderr, "Skipping test: English Unicode locale is not installed\n");
33 return 77;
36 mb_file_t mbstdin;
37 mbf_init (mbstdin, stdin);
38 /* The input consists of 4 UTF-8 characters:
39 '$', U+00A5, U+20AC, U+0001F403. */
40 mbf_char_t next;
42 mbf_getc (next, mbstdin);
43 ASSERT (!mb_iseof (next));
44 ASSERT (mb_len (next) == 1);
45 ASSERT (mb_iseq (next, 0x0024));
47 mbf_getc (next, mbstdin);
48 ASSERT (!mb_iseof (next));
49 ASSERT (mb_len (next) == 2);
50 ASSERT (mb_iseq (next, 0x00A5));
52 mbf_getc (next, mbstdin);
53 ASSERT (!mb_iseof (next));
54 ASSERT (mb_len (next) == 3);
55 ASSERT (mb_iseq (next, 0x20AC));
57 mbf_getc (next, mbstdin);
58 ASSERT (!mb_iseof (next));
59 ASSERT (mb_len (next) == 4);
60 ASSERT (mb_iseq (next, 0x1F403));
62 mbf_getc (next, mbstdin);
63 ASSERT (mb_iseof (next));
65 return test_exit_status;