Mercurial > gnulib
annotate tests/uninorm/test-u32-nfd-big.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 | 5b87a9bf7240 |
rev | line source |
---|---|
11193 | 1 /* Test of Unicode compliance of canonical decomposition of UTF-32 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. |
11193 | 3 |
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. | |
8 | |
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. | |
13 | |
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/>. */ |
11193 | 16 |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */ | |
18 | |
19 #include <config.h> | |
20 | |
13073
03de1efbfdd3
Resolve conflict between the two kinds of module indicators.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
21 #if GNULIB_TEST_UNINORM_U32_NORMALIZE |
11193 | 22 |
23 #include "uninorm.h" | |
24 | |
25 #include <stdlib.h> | |
26 | |
27 #include "unistr.h" | |
28 #include "test-u32-normalize-big.h" | |
29 | |
30 static int | |
31 check (const uint32_t *c1, size_t c1_length, | |
32 const uint32_t *c2, size_t c2_length, | |
33 const uint32_t *c3, size_t c3_length, | |
34 const uint32_t *c4, size_t c4_length, | |
35 const uint32_t *c5, size_t c5_length) | |
36 { | |
37 /* Check | |
38 c3 == NFD(c1) == NFD(c2) == NFD(c3) | |
39 c5 == NFD(c4) == NFD(c5) | |
40 */ | |
41 { | |
42 size_t length; | |
43 uint32_t *result; | |
44 | |
45 result = u32_normalize (UNINORM_NFD, c1, c1_length, NULL, &length); | |
46 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
47 && length == c3_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
48 && u32_cmp (result, c3, c3_length) == 0)) |
11193 | 49 return 1; |
50 free (result); | |
51 } | |
52 { | |
53 size_t length; | |
54 uint32_t *result; | |
55 | |
56 result = u32_normalize (UNINORM_NFD, c2, c2_length, NULL, &length); | |
57 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
58 && length == c3_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
59 && u32_cmp (result, c3, c3_length) == 0)) |
11193 | 60 return 2; |
61 free (result); | |
62 } | |
63 { | |
64 size_t length; | |
65 uint32_t *result; | |
66 | |
67 result = u32_normalize (UNINORM_NFD, c3, c3_length, NULL, &length); | |
68 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
69 && length == c3_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
70 && u32_cmp (result, c3, c3_length) == 0)) |
11193 | 71 return 3; |
72 free (result); | |
73 } | |
74 { | |
75 size_t length; | |
76 uint32_t *result; | |
77 | |
78 result = u32_normalize (UNINORM_NFD, c4, c4_length, NULL, &length); | |
79 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
80 && length == c5_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
81 && u32_cmp (result, c5, c5_length) == 0)) |
11193 | 82 return 4; |
83 free (result); | |
84 } | |
85 { | |
86 size_t length; | |
87 uint32_t *result; | |
88 | |
89 result = u32_normalize (UNINORM_NFD, c5, c5_length, NULL, &length); | |
90 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
91 && length == c5_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
92 && u32_cmp (result, c5, c5_length) == 0)) |
11193 | 93 return 5; |
94 free (result); | |
95 } | |
96 return 0; | |
97 } | |
98 | |
99 int | |
100 main (int argc, char *argv[]) | |
101 { | |
102 struct normalization_test_file file; | |
103 | |
104 read_normalization_test_file (argv[1], &file); | |
105 | |
106 test_specific (&file, check); | |
107 test_other (&file, UNINORM_NFD); | |
108 | |
109 return 0; | |
110 } | |
111 | |
112 #else | |
113 | |
114 #include <stdio.h> | |
115 | |
116 int | |
117 main () | |
118 { | |
119 fprintf (stderr, "Skipping test: uninorm/u32-normalize module not included.\n"); | |
120 return 77; | |
121 } | |
122 | |
123 #endif |