Mercurial > gnulib
annotate tests/unicase/test-u8-totitle.c @ 40057:b06060465f09
maint: Run 'make update-copyright'
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 01 Jan 2019 00:25:11 +0100 |
parents | 10eb9086bea0 |
children |
rev | line source |
---|---|
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of titlecase mapping for UTF-8 strings. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 Copyright (C) 2009-2019 Free Software Foundation, Inc. |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
19190 | 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include "unicase.h" |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include <stdlib.h> |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 #include "unistr.h" |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 #include "uninorm.h" |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
27 #include "macros.h" |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 static int |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 check (const uint8_t *input, size_t input_length, |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 const char *iso639_language, uninorm_t nf, |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 const uint8_t *expected, size_t expected_length) |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 { |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 size_t length; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 uint8_t *result; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 /* Test return conventions with resultbuf == NULL. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 result = u8_totitle (input, input_length, iso639_language, nf, NULL, &length); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 if (!(result != NULL)) |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 return 1; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 if (!(length == expected_length)) |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 return 2; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 if (!(u8_cmp (result, expected, expected_length) == 0)) |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 return 3; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 free (result); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 /* Test return conventions with resultbuf too small. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 if (expected_length > 0) |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 { |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 uint8_t *preallocated; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 length = expected_length - 1; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 preallocated = (uint8_t *) malloc (length * sizeof (uint8_t)); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 result = u8_totitle (input, input_length, iso639_language, nf, preallocated, &length); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 if (!(result != NULL)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
56 return 4; |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 if (!(result != preallocated)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
58 return 5; |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 if (!(length == expected_length)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
60 return 6; |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 if (!(u8_cmp (result, expected, expected_length) == 0)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
62 return 7; |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 free (result); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 free (preallocated); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 /* Test return conventions with resultbuf large enough. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 { |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 uint8_t *preallocated; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 length = expected_length; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 preallocated = (uint8_t *) malloc (length * sizeof (uint8_t)); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 result = u8_totitle (input, input_length, iso639_language, nf, preallocated, &length); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 if (!(result != NULL)) |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 return 8; |
11466
f8e64c4210ee
Avoid test failures on AIX and OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
11325
diff
changeset
|
76 if (!(preallocated == NULL || result == preallocated)) |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 return 9; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 if (!(length == expected_length)) |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 return 10; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 if (!(u8_cmp (result, expected, expected_length) == 0)) |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 return 11; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
82 free (preallocated); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 return 0; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
86 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
87 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
88 int |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
89 main () |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
90 { |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
91 { /* Empty string. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
92 ASSERT (check (NULL, 0, NULL, NULL, NULL, 0) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
93 ASSERT (check (NULL, 0, NULL, UNINORM_NFC, NULL, 0) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
94 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
95 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
96 /* Simple string. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
97 { /* "GRÜß GOTT. ЗДРАВСТВУЙТЕ! X=(-B±SQRT(B²-4AC))/(2A) 日本語,中文,한글" */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
98 static const uint8_t input[] = |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
99 { 'G', 'R', 0xC3, 0x9C, 0xC3, 0x9F, ' ', 'G', 'O', 'T', 'T', '.', ' ', |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
100 0xD0, 0x97, 0xD0, 0x94, 0xD0, 0xA0, 0xD0, 0x90, 0xD0, 0x92, 0xD0, 0xA1, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
101 0xD0, 0xA2, 0xD0, 0x92, 0xD0, 0xA3, 0xD0, 0x99, 0xD0, 0xA2, 0xD0, 0x95, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
102 '!', ' ', 'X', '=', '(', '-', 'B', 0xC2, 0xB1, 'S', 'Q', 'R', 'T', '(', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
103 'B', 0xC2, 0xB2, '-', '4', 'A', 'C', ')', ')', '/', '(', '2', 'A', ')', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
104 ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC, 0xE8, 0xAA, 0x9E, ',', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
105 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
106 0xED, 0x95, 0x9C, 0xEA, 0xB8, 0x80, '\n' |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
107 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
108 static const uint8_t casemapped[] = |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
109 { 'G', 'r', 0xC3, 0xBC, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.', ' ', |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
110 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1, 0x81, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
111 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9, 0xD1, 0x82, 0xD0, 0xB5, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
112 '!', ' ', 'X', '=', '(', '-', 'B', 0xC2, 0xB1, 'S', 'q', 'r', 't', '(', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
113 'B', 0xC2, 0xB2, '-', '4', 'A', 'c', ')', ')', '/', '(', '2', 'A', ')', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
114 ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC, 0xE8, 0xAA, 0x9E, ',', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
115 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
116 0xED, 0x95, 0x9C, 0xEA, 0xB8, 0x80, '\n' |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
117 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
118 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
119 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
120 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
121 /* Case mapping can increase the number of Unicode characters. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
122 { /* LATIN SMALL LETTER N PRECEDED BY APOSTROPHE */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
123 static const uint8_t input[] = { 0xC5, 0x89 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
124 static const uint8_t casemapped[] = { 0xCA, 0xBC, 0x4E }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
125 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
126 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
127 { /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
128 static const uint8_t input[] = { 0xCE, 0x90 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
129 static const uint8_t casemapped[] = { 0xCE, 0x99, 0xCC, 0x88, 0xCC, 0x81 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
130 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
131 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
132 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
133 /* Turkish letters i İ ı I */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
134 { /* LATIN CAPITAL LETTER I */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
135 static const uint8_t input[] = { 0x49 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
136 static const uint8_t casemapped[] = { 0x49 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
137 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
138 ASSERT (check (input, SIZEOF (input), "tr", NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
139 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
140 { /* LATIN SMALL LETTER I */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
141 static const uint8_t input[] = { 0x69 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
142 static const uint8_t casemapped[] = { 0x49 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
143 static const uint8_t casemapped_tr[] = { 0xC4, 0xB0 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
144 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
145 ASSERT (check (input, SIZEOF (input), "tr", NULL, casemapped_tr, SIZEOF (casemapped_tr)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
146 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
147 { /* LATIN CAPITAL LETTER I WITH DOT ABOVE */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
148 static const uint8_t input[] = { 0xC4, 0xB0 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
149 static const uint8_t casemapped[] = { 0xC4, 0xB0 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
150 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
151 ASSERT (check (input, SIZEOF (input), "tr", NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
152 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
153 { /* LATIN SMALL LETTER DOTLESS I */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
154 static const uint8_t input[] = { 0xC4, 0xB1 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
155 static const uint8_t casemapped[] = { 0x49 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
156 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
157 ASSERT (check (input, SIZEOF (input), "tr", NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
158 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
159 { /* "topkapı" */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
160 static const uint8_t input[] = |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
161 { 0x74, 0x6F, 0x70, 0x6B, 0x61, 0x70, 0xC4, 0xB1 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
162 static const uint8_t casemapped[] = |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
163 { 0x54, 0x6F, 0x70, 0x6B, 0x61, 0x70, 0xC4, 0xB1 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
164 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
165 ASSERT (check (input, SIZEOF (input), "tr", NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
166 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
167 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
168 /* Uppercasing can increase the number of Unicode characters. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
169 { /* "heiß" */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
170 static const uint8_t input[] = { 0x68, 0x65, 0x69, 0xC3, 0x9F }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
171 static const uint8_t casemapped[] = { 0x48, 0x65, 0x69, 0xC3, 0x9F }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
172 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
173 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
174 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
175 /* Case mappings for some characters can depend on the surrounding characters. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
176 { /* "περισσότερες πληροφορίες" */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
177 static const uint8_t input[] = |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
178 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
179 0xCF, 0x80, 0xCE, 0xB5, 0xCF, 0x81, 0xCE, 0xB9, 0xCF, 0x83, 0xCF, 0x83, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
180 0xCF, 0x8C, 0xCF, 0x84, 0xCE, 0xB5, 0xCF, 0x81, 0xCE, 0xB5, 0xCF, 0x82, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
181 ' ', 0xCF, 0x80, 0xCE, 0xBB, 0xCE, 0xB7, 0xCF, 0x81, 0xCE, 0xBF, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
182 0xCF, 0x86, 0xCE, 0xBF, 0xCF, 0x81, 0xCE, 0xAF, 0xCE, 0xB5, 0xCF, 0x82 |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
183 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
184 static const uint8_t casemapped[] = |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
185 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
186 0xCE, 0xA0, 0xCE, 0xB5, 0xCF, 0x81, 0xCE, 0xB9, 0xCF, 0x83, 0xCF, 0x83, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
187 0xCF, 0x8C, 0xCF, 0x84, 0xCE, 0xB5, 0xCF, 0x81, 0xCE, 0xB5, 0xCF, 0x82, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
188 ' ', 0xCE, 0xA0, 0xCE, 0xBB, 0xCE, 0xB7, 0xCF, 0x81, 0xCE, 0xBF, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11466
diff
changeset
|
189 0xCF, 0x86, 0xCE, 0xBF, 0xCF, 0x81, 0xCE, 0xAF, 0xCE, 0xB5, 0xCF, 0x82 |
11325
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
190 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
191 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
192 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
193 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
194 /* Case mapping can require subsequent normalization. */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
195 { /* LATIN SMALL LETTER J WITH CARON, COMBINING DOT BELOW */ |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
196 static const uint8_t input[] = { 0xC7, 0xB0, 0xCC, 0xA3 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
197 static const uint8_t casemapped[] = { 0x4A, 0xCC, 0x8C, 0xCC, 0xA3 }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
198 static const uint8_t casemapped_normalized[] = { 0x4A, 0xCC, 0xA3, 0xCC, 0x8C }; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
199 ASSERT (check (input, SIZEOF (input), NULL, NULL, casemapped, SIZEOF (casemapped)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
200 ASSERT (check (input, SIZEOF (input), NULL, UNINORM_NFC, casemapped_normalized, SIZEOF (casemapped_normalized)) == 0); |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
201 } |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
202 |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
203 return 0; |
3f3eea92a179
Tests for module 'unicase/u8-totitle'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
204 } |