1 /* Grapheme cluster breaks test.
2 Copyright (C) 2009, 2010, 2011 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 <http://www.gnu.org/licenses/>. */
17 /* Written by Ben Pfaff <blp@cs.stanford.edu>, 2010,
18 based on code by Bruno Haible <bruno@clisp.org>, 2009. */
30 is_8859_6_break (unsigned char c)
32 /* ISO-8859-6 has combining characters in positions 0xeb through 0xf2. */
33 return !(c >= 0xeb && c <= 0xf2);
39 /* configure should already have checked that the locale is supported. */
40 if (setlocale (LC_ALL, "") == NULL)
43 /* Test case n = 0. */
44 ulc_grapheme_breaks (NULL, 0, NULL);
48 /* This is just a random collection of bytes from ISO-8859-6.
50 (We use ISO-8859-6 because it is one of very few non-UTF-8 locale
51 encodings supported by glibc that have combining characters.) */
52 static const char s[] = "ZYX\352\353W\360\361V\362";
53 enum { LENGTH = sizeof s - 1 };
57 ulc_grapheme_breaks (s, LENGTH, p);
58 for (i = 0; i < LENGTH; i++)
59 if (p[i] != is_8859_6_break (s[i]))
63 fprintf (stderr, "wrong grapheme breaks:\n");
65 fprintf (stderr, " input:");
66 for (j = 0; j < LENGTH; j++)
67 fprintf (stderr, " %02x", (unsigned char) s[j]);
70 fprintf (stderr, "expected:");
71 for (j = 0; j < LENGTH; j++)
72 fprintf (stderr, " %d", is_8859_6_break (s[j]));
75 fprintf (stderr, " actual:");
76 for (j = 0; j < LENGTH; j++)
77 fprintf (stderr, " %d", p[j]);