Mercurial > hg > octave-nkf > gnulib-hg
annotate tests/unilbrk/test-u32-width-linebreaks.c @ 12496:a48d3d749ca5
Refactor common macros used in tests.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 24 Dec 2009 21:01:42 +0100 |
parents | e8d2c6fc33ad |
children | c2cbabec01dd |
rev | line source |
---|---|
10048
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of line breaking of UTF-32 strings. |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
2 Copyright (C) 2008-2009 Free Software Foundation, Inc. |
10048
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2008. */ |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include "unilbrk.h" |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include <stdlib.h> |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
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" |
10048
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 int |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 main () |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 { |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 /* Test case n = 0. */ |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 u32_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL); |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 { |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 static const uint32_t input[61] = |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */ |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 { 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ', |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
37 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
38 0x0439, 0x0442, 0x0435, '!', ' ', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
39 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
40 '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
41 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n' |
10048
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 }; |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 { |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 char *p = (char *) malloc (SIZEOF (input)); |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 size_t i; |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 u32_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p); |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 for (i = 0; i < 61; i++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
50 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
51 ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
52 i == 25 || i == 45 ? UC_BREAK_POSSIBLE : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
53 UC_BREAK_PROHIBITED)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
54 } |
10048
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 free (p); |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 } |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 { |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 char *p = (char *) malloc (SIZEOF (input)); |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 size_t i; |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 u32_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p); |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 for (i = 0; i < 61; i++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
64 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
65 ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
66 i == 11 || i == 25 || i == 45 ? UC_BREAK_POSSIBLE : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
67 UC_BREAK_PROHIBITED)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10063
diff
changeset
|
68 } |
10048
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 free (p); |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 } |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 } |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 return 0; |
db20f16c3277
Tests for module 'unilbrk/u32-width-linebreaks'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 } |