1 /* Test some mathematical operator transliterations (BZ #23132)
3 Copyright (C) 2019-2023 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the 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 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
24 #include <support/check.h>
38 const char str
[] = "\u27E6 \u27E7 \u27E8 \u27E9"
39 " \u27EC \u27ED \u2980"
40 " \u2983 \u2984 \u2985 \u2986"
41 " \u2987 \u2988 \u2989 \u298A"
42 " \u29E3 \u29E5 \u29F5 \u29F8 \u29F9"
43 " \u29FC \u29FD \u29FE \u29FF";
45 const char expected
[] = "[| |] < >"
52 char *inptr
= (char *) str
;
53 size_t inlen
= strlen (str
) + 1;
55 char *outptr
= outbuf
;
56 size_t outlen
= sizeof (outbuf
);
60 if (setlocale (LC_ALL
, "en_US.UTF-8") == NULL
)
61 FAIL_EXIT1 ("setlocale failed");
63 cd
= iconv_open ("ASCII//TRANSLIT", "UTF-8");
64 if (cd
== (iconv_t
) -1)
65 FAIL_EXIT1 ("iconv_open failed");
67 n
= iconv (cd
, &inptr
, &inlen
, &outptr
, &outlen
);
71 printf ("iconv() returned error: %m\n");
73 printf ("iconv() returned %zd, expected 24\n", n
);
78 puts ("not all input consumed");
81 else if (inptr
- str
!= strlen (str
) + 1)
83 printf ("inptr wrong, advanced by %td\n", inptr
- str
);
86 if (memcmp (outbuf
, expected
, sizeof (expected
)) != 0)
88 printf ("result wrong: \"%.*s\", expected: \"%s\"\n",
89 (int) (sizeof (outbuf
) - outlen
), outbuf
, expected
);
92 else if (outlen
!= sizeof (outbuf
) - sizeof (expected
))
94 printf ("outlen wrong: %zd, expected %zd\n", outlen
,
95 sizeof (outbuf
) - 15);
99 printf ("output is \"%s\" which is OK\n", outbuf
);
104 #include <support/test-driver.c>