powerpc: Fix VSX register number on __strncpy_power9 [BZ #29197]
[glibc.git] / localedata / tst-iconv-math-trans.c
bloba2d01a7e34f9cf166162de613b2144c7c561994d
1 /* Test some mathematical operator transliterations (BZ #23132)
3 Copyright (C) 2019-2022 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/>. */
20 #include <iconv.h>
21 #include <locale.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include <support/check.h>
26 static int
27 do_test (void)
29 iconv_t cd;
31 /* str[] = "⟦ ⟧ ⟨ ⟩"
32 " ⟬ ⟭ ⦀"
33 " ⦃ ⦄ ⦅ ⦆"
34 " ⦇ ⦈ ⦉ ⦊"
35 " ⧣ ⧥ ⧵ ⧸ ⧹"
36 " ⧼ ⧽ ⧾ ⧿"; */
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[] = "[| |] < >"
46 " (( )) |||"
47 " {| |} (( ))"
48 " (| |) <| |>"
49 " # # \\ / \\"
50 " < > + -";
52 char *inptr = (char *) str;
53 size_t inlen = strlen (str) + 1;
54 char outbuf[500];
55 char *outptr = outbuf;
56 size_t outlen = sizeof (outbuf);
57 int result = 0;
58 size_t n;
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);
68 if (n != 24)
70 if (n == (size_t) -1)
71 printf ("iconv() returned error: %m\n");
72 else
73 printf ("iconv() returned %Zd, expected 24\n", n);
74 result = 1;
76 if (inlen != 0)
78 puts ("not all input consumed");
79 result = 1;
81 else if (inptr - str != strlen (str) + 1)
83 printf ("inptr wrong, advanced by %td\n", inptr - str);
84 result = 1;
86 if (memcmp (outbuf, expected, sizeof (expected)) != 0)
88 printf ("result wrong: \"%.*s\", expected: \"%s\"\n",
89 (int) (sizeof (outbuf) - outlen), outbuf, expected);
90 result = 1;
92 else if (outlen != sizeof (outbuf) - sizeof (expected))
94 printf ("outlen wrong: %Zd, expected %Zd\n", outlen,
95 sizeof (outbuf) - 15);
96 result = 1;
98 else
99 printf ("output is \"%s\" which is OK\n", outbuf);
101 return result;
104 #include <support/test-driver.c>