Mercurial > gnulib
annotate tests/uninorm/test-u32-nfd-big.c @ 12559:c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Use the same procedure as for 2009, outlined in
http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Fri, 01 Jan 2010 10:31:12 +0100 |
parents | e8d2c6fc33ad |
children | 03de1efbfdd3 |
rev | line source |
---|---|
11193 | 1 /* Test of Unicode compliance of canonical decomposition of UTF-32 strings. |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12421
diff
changeset
|
2 Copyright (C) 2009, 2010 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 | |
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
16 | |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */ | |
18 | |
19 #include <config.h> | |
20 | |
21 #if GNULIB_UNINORM_U32_NORMALIZE | |
22 | |
23 #include "uninorm.h" | |
24 | |
25 #include <stdlib.h> | |
26 | |
27 #include "unistr.h" | |
28 #include "progname.h" | |
29 #include "test-u32-normalize-big.h" | |
30 | |
31 static int | |
32 check (const uint32_t *c1, size_t c1_length, | |
33 const uint32_t *c2, size_t c2_length, | |
34 const uint32_t *c3, size_t c3_length, | |
35 const uint32_t *c4, size_t c4_length, | |
36 const uint32_t *c5, size_t c5_length) | |
37 { | |
38 /* Check | |
39 c3 == NFD(c1) == NFD(c2) == NFD(c3) | |
40 c5 == NFD(c4) == NFD(c5) | |
41 */ | |
42 { | |
43 size_t length; | |
44 uint32_t *result; | |
45 | |
46 result = u32_normalize (UNINORM_NFD, c1, c1_length, NULL, &length); | |
47 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
48 && length == c3_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
49 && u32_cmp (result, c3, c3_length) == 0)) |
11193 | 50 return 1; |
51 free (result); | |
52 } | |
53 { | |
54 size_t length; | |
55 uint32_t *result; | |
56 | |
57 result = u32_normalize (UNINORM_NFD, c2, c2_length, NULL, &length); | |
58 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
59 && length == c3_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
60 && u32_cmp (result, c3, c3_length) == 0)) |
11193 | 61 return 2; |
62 free (result); | |
63 } | |
64 { | |
65 size_t length; | |
66 uint32_t *result; | |
67 | |
68 result = u32_normalize (UNINORM_NFD, c3, c3_length, NULL, &length); | |
69 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
70 && length == c3_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
71 && u32_cmp (result, c3, c3_length) == 0)) |
11193 | 72 return 3; |
73 free (result); | |
74 } | |
75 { | |
76 size_t length; | |
77 uint32_t *result; | |
78 | |
79 result = u32_normalize (UNINORM_NFD, c4, c4_length, NULL, &length); | |
80 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
81 && length == c5_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
82 && u32_cmp (result, c5, c5_length) == 0)) |
11193 | 83 return 4; |
84 free (result); | |
85 } | |
86 { | |
87 size_t length; | |
88 uint32_t *result; | |
89 | |
90 result = u32_normalize (UNINORM_NFD, c5, c5_length, NULL, &length); | |
91 if (!(result != NULL | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
92 && length == c5_length |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11193
diff
changeset
|
93 && u32_cmp (result, c5, c5_length) == 0)) |
11193 | 94 return 5; |
95 free (result); | |
96 } | |
97 return 0; | |
98 } | |
99 | |
100 int | |
101 main (int argc, char *argv[]) | |
102 { | |
103 struct normalization_test_file file; | |
104 | |
105 set_program_name (argv[0]); | |
106 read_normalization_test_file (argv[1], &file); | |
107 | |
108 test_specific (&file, check); | |
109 test_other (&file, UNINORM_NFD); | |
110 | |
111 return 0; | |
112 } | |
113 | |
114 #else | |
115 | |
116 #include <stdio.h> | |
117 | |
118 int | |
119 main () | |
120 { | |
121 fprintf (stderr, "Skipping test: uninorm/u32-normalize module not included.\n"); | |
122 return 77; | |
123 } | |
124 | |
125 #endif |