Mercurial > hg > octave-nkf > gnulib-hg
annotate tests/uniwbrk/test-u8-wordbreaks.c @ 16817:7747cb9b54b9
unistd_h: make it easier to avoid sys_types_h
This is useful for Emacs, which has its own method of porting to
Windows, and which therefore does not need the sys_types_h module.
* m4/off_t.m4: New file, defining gl_TYPE_OFF_T, which contains
code moved here from gl_SYS_TYPES_H.
* m4/sys_types_h.m4 (gl_SYS_TYPES_H): Require it instead of
using the code directly.
* m4/unistd_h.m4 (gl_UNISTD_H): Require gl_TYPE_OFF_T, not
gl_SYS_TYPES_H.
* modules/sys_types (Files):
* modules/unistd (Files): Add m4/off_t.m4.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 04 May 2012 13:05:31 -0700 |
parents | 8250f2777afc |
children | e542fd46ad6f |
rev | line source |
---|---|
11158
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of word breaks in UTF-8 strings. |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
14079
diff
changeset
|
2 Copyright (C) 2009-2012 Free Software Foundation, Inc. |
11158
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */ |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include "uniwbrk.h" |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include <stdlib.h> |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
25 #include "macros.h" |
11158
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 int |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 main () |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 { |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 /* Test case n = 0. */ |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 u8_wordbreaks (NULL, 0, NULL); |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 { |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 static const uint8_t input[91] = |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */ |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 "Gr\303\274\303\237 Gott. \320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\271\321\202\320\265! x=(-b\302\261sqrt(b\302\262-4ac))/(2a) \346\227\245\346\234\254\350\252\236,\344\270\255\346\226\207,\355\225\234\352\270\200\n"; |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 char *p = (char *) malloc (SIZEOF (input)); |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 size_t i; |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 u8_wordbreaks (input, SIZEOF (input), p); |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 for (i = 0; i < 91; i++) |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
44 ASSERT (p[i] == ((i >= 6 && i <= 7) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
45 || (i >= 11 && i <= 13) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
46 || (i >= 37 && i <= 44) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
47 || i == 46 || (i >= 50 && i <= 52) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
48 || (i >= 54 && i <= 55) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
49 || (i >= 58 && i <= 62) || (i >= 64 && i <= 67) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
50 || i == 70 || i == 73 || i == 76 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
51 || i == 77 || i == 80 || i == 83 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
52 || i == 84 || i == 90 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
53 ? 1 : 0)); |
11158
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 } |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 free (p); |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 } |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 { |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 /* Same input string, decomposed. */ |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 static const uint8_t input[106] = |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */ |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 "Gru\314\210\303\237 Gott. \320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\270\314\206\321\202\320\265! x=(-b\302\261sqrt(b\302\262-4ac))/(2a) \346\227\245\346\234\254\350\252\236,\344\270\255\346\226\207,\341\204\222\341\205\241\341\206\253\341\204\200\341\205\263\341\206\257\n"; |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 char *p = (char *) malloc (SIZEOF (input)); |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 size_t i; |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 u8_wordbreaks (input, SIZEOF (input), p); |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 for (i = 0; i < 106; i++) |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
70 ASSERT (p[i] == ((i >= 7 && i <= 8) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
71 || (i >= 12 && i <= 14) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
72 || (i >= 40 && i <= 47) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
73 || i == 49 || (i >= 53 && i <= 55) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
74 || (i >= 57 && i <= 58) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
75 || (i >= 61 && i <= 65) || (i >= 67 && i <= 70) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
76 || i == 73 || i == 76 || i == 79 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
77 || i == 80 || i == 83 || i == 86 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
78 || i == 87 || i == 105 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11158
diff
changeset
|
79 ? 1 : 0)); |
11158
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 } |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 free (p); |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
82 } |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 return 0; |
292bb6ed6b7b
Tests for module 'uniwbrk/u8-wordbreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 } |